How do you get a desktop user-agent for iPad with WebKit?

I need to get my iPad to use the desktop version of a user agent however so far this is not working

Code Block
 let webConfiguration = WKWebViewConfiguration()
 if #available(iOS 13.0, *) {
      webConfiguration.defaultWebpagePreferences.preferredContentMode = .desktop
} else {
      // Fallback on earlier versions
}
let webView = WKWebView(frame: .zero, configuration: webConfiguration)
webView.evaluateJavaScript("navigator.userAgent") { result, _ in
      var userAgent: UIAlertController!
      userAgent = UIAlertController(title: "user agent", message: result as? String, preferredStyle: .alert)
      userAgent.addAction(UIAlertAction(title: "Ok", style: .default, handler: nil))
      UIApplication.shared.windows.first?.rootViewController?.present(userAgent, animated: false, completion: nil)
}


(UPDATED)
Seems you have edited your first post.
What is the problem with your latest code?
hey
I am getting this as a result:

"Mozilla/5.0 (iPad; CPU OS 133 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148" instead of

"Mozilla/5.0 (Macintosh; Intel Mac OS X 10
15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36 Edg/87.0.664.75"

I am getting this as a result:

Why does it matter?
If WKWebView returned the String, then isn't it the User-Agent sent to the server?

How do you get a desktop user-agent for iPad with WebKit?

Aren't you just examining the User-Agent?

Or do you want to force some specific User-Agent?
I agree, it seems like if you set preferredContentMode to desktop, then the User Agent should probably be "desktop".

However, WKWebView has a customUserAgent property, so you can just use some string manipulation to "fix it".
How do you get a desktop user-agent for iPad with WebKit?
 
 
Q