简体   繁体   English

iOS WKWebview UserAgent 正在 iPhone 上设置,但不适用于 iPad

[英]iOS WKWebview UserAgent is being set on iPhone but not for iPad

When I open or launch the site on iPhone in wkwebview it gets the application "userAgent" in the request Header automatically but in the same scenario it is not happening for iPad.当我在 wkwebview 中打开或启动 iPhone 上的网站时,它会自动在请求 Header 中获取应用程序“userAgent”,但在相同的情况下,iPad 不会发生这种情况。

Creation of the WKWebview below:下面创建 WKWebview:

let wkWebView = WKWebView()让 wkWebView = WKWebView()

You can create WKWebViewConfiguration and pass it with WKWebView creation.您可以创建WKWebViewConfiguration并将其与WKWebView创建一起传递。

// Create custom configuration object.
let webConfiguration = WKWebViewConfiguration()
webConfiguration.applicationNameForUserAgent = "Add your user agent here."

// Create WebView object with your configuration object.
let webView = WKWebView(frame: view.frame, configuration: webConfiguration)

This way it will work for all your devices.这样它将适用于您的所有设备。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM