除了使用以下方法之外,还有其他方法可以获得iOS浏览器UserAgent字符串吗?请帮忙。
WKWebView *webView = [[WKWebView alloc] initWithFrame:self.view.bounds];
[webView loadHTMLString:@"<html></html>" baseURL:nil];
[webView evaluateJavaScript:@"navigator.userAgent" completionHandler:^(id __nullable userAgent, NSError * __nullable error) {
NSLog(@"%@", userAgent);
}];
答案 0 :(得分:2)
试试这个:
UIWebView* webView = [[UIWebView alloc] initWithFrame:CGRectZero];
NSString *userAgent = [webView stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"];