VERSION
iOS 12 beta5 (16A5339e)
ISSUE
Set customUserAgent on WKWebView not work on iOS 12 beta5 (16A5339e). While it will modify UserAgent successfully on iOS beta4 (16A5288q).
Sample
- (WKWebView *)webView {
if (!_webView) {
_webView = ({
WKWebViewConfiguration* configuration = [[WKWebViewConfiguration alloc] init];
WKWebView* webView = [[WKWebView alloc] initWithFrame:self.view.bounds
configuration:configuration];
[self.view addSubview:webView];
webView;
});
}
return _webView;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self.webView evaluateJavaScript:@"navigator.userAgent" completionHandler:^(id _Nullable result, NSError * _Nullable error) {
NSString* originUserAgent = result;
NSString* newUserAgent = [NSString stringWithFormat:@"%@ %@", originUserAgent, @"NOTHING APPENDED ON BETA5"];
self.webView.customUserAgent = newUserAgent;
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://www.google.com"]]];
}];
}