Skip to content

Instantly share code, notes, and snippets.

@hiroshido
Created December 17, 2013 10:51
Show Gist options
  • Save hiroshido/8003086 to your computer and use it in GitHub Desktop.
Save hiroshido/8003086 to your computer and use it in GitHub Desktop.
Webviewのnavigator.userAgentを独自のユーザーエージェントにする方法と、その他諸注意(Googel Analytics etc..) ref: http://qiita.com/unamu/items/078ca02c0e3444247ac4
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectZero];
NSString *userAgent = [webView stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"];
NSString *customUserAgent = [userAgent stringByAppendingString:@" HOGEHOGE"];
NSDictionary *dictionary = [[NSDictionary alloc] initWithObjectsAndKeys:customUserAgent , @"UserAgent", nil];
[[NSUserDefaults standardUserDefaults] registerDefaults:dictionary];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment