Post

Replies

Boosts

Views

Activity

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  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) }
5
0
2.2k
Jan ’21