Created
May 21, 2020 01:30
-
-
Save tigi44/c66d24e7beb0c8be7e2495910036dedc to your computer and use it in GitHub Desktop.
[iOS, Objective-c] WKWebView Custom User-Agent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)setupCustomUserAgent | |
{ | |
[self.webView evaluateJavaScript:@"navigator.userAgent" completionHandler:^(NSString *aUserAgent, NSError *aError) { | |
NSString *sCustomUserAgent = @"additional custom user-agent"; | |
if (aUserAgent.length > 0 && aError == nil) { | |
sCustomUserAgent = [NSString stringWithFormat:@"%@ %@", aUserAgent, sCustomUserAgent]; | |
} | |
self.webView.customUserAgent = sCustomUserAgent; | |
}]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment