UIWebView iOS5 changing user-agent

Change the “UserAgent” default value by running this code once when your app starts:

NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:@"Your user agent", @"UserAgent", nil];
[[NSUserDefaults standardUserDefaults] registerDefaults:dictionary];  

EDIT: I have used this with great success, but want to add additional details. To get a user agent, you can enable the “Developer” menu, set the user agent, and then connect to this site to get it printed out for you: WhatsMyAgent. Likewise you can connect using any kind of mobile device, and get it that way too. BTW this is still working just fine in iOS7+

Leave a Comment