UIWebView 添加 UA 标识
2019-04-10 本文已影响0人
世玉茹花
UIWebView 添加 UA 标识。
//get the original user-agent of
webviewUIWebView*webView = [[UIWebViewalloc] initWithFrame:CGRectZero];
NSString*oldAgent = [webView stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"];
NSLog(@"old agent :%@", oldAgent);//add my info to the new agent
NSString*newAgent = [oldAgent stringByAppendingString:@"Bobo_Ma"];
NSLog(@"new agent :%@", newAgent);//regist the new agent
NSDictionary*dictionnary = [[NSDictionaryalloc] initWithObjectsAndKeys:newAgent,@"UserAgent",nil];
[[NSUserDefaultsstandardUserDefaults] registerDefaults:dictionnary];