Skip to content

Instantly share code, notes, and snippets.

@Hafthor
Created October 19, 2013 00:23
Show Gist options
  • Save Hafthor/7050213 to your computer and use it in GitHub Desktop.
Save Hafthor/7050213 to your computer and use it in GitHub Desktop.
Allow cookies and set user agent on UIWebViews
[NSHTTPCookieStorage sharedHTTPCookieStorage].cookieAcceptPolicy = NSHTTPCookieAcceptPolicyAlways;
NSString *userAgent = [[[UIWebView alloc] initWithFrame:CGRectZero] stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"];
[[NSUserDefaults standardUserDefaults] registerDefaults:@{@"UserAgent": [userAgent stringByAppendingString:@" Version/7.0 Safari/9537.53"]}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment