问题
I'm trying to get the user-agent from WKWebView by using swift,
let webView = WKWebView(frame: .zero)
useragentlabel.text = webView.configuration.applicationNameForUserAgent
but it return Mobile/15E148
, it s can be that the user-agent ?
thanks
回答1:
[self.webView evaluateJavaScript:@"navigator.userAgent" completionHandler:^(id _Nullable result, NSError * _Nullable error) {
}];
The result is userAgent
回答2:
This gets the user agent:
let userAgent = webView.customUserAgent!
来源:https://stackoverflow.com/questions/58337691/wkwebview-user-agent-swift