Reputation: 4425
Is there any other ways to get iOS browser UserAgent string other than using the following methodology? Please help.
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);
}];
Upvotes: 2
Views: 2390
Reputation: 53
Try this :
UIWebView* webView = [[UIWebView alloc] initWithFrame:CGRectZero];
NSString *userAgent = [webView stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"];
Upvotes: 2