To add custom content to the current UserAgent value, do the following:
1 - Get user agent value from NEW WEBVIEW
2 - add custom content to it
3 - Save the new value in the dictionary using the UserAgent key
4 - Save the dictionary in the standard UserDefaults.
See an example below:
NSString *userAgentP1 = [[[UIWebView alloc] init] stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"]; NSString *userAgentP2 = @"My_custom_value"; NSString *userAgent = [NSString stringWithFormat:@"%@ %@", userAgentP1, userAgentP2]; NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:userAgent, @"UserAgent", nil]; [[NSUserDefaults standardUserDefaults] registerDefaults:dictionary];
Doug Sep 11 '15 at 19:02 2015-09-11 19:02
source share