using IBM MobileFirst Platform 7.0 I am unable to modify the user agent of a UIWebView. I have a hybrid application (HTML/CSS, JS, Objective-C) and tried UIWebView iOS5 changing user-agent (both question and answer version):
@implementation MyAppDelegate
+ (void)initialize
{
NSString* useragent = @"Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0";
NSLog(@"Setting User-Agent to: %@", useragent);
NSDictionary* dictionary = [NSDictionary dictionaryWithObjectsAndKeys:useragent, @"UserAgent", nil];
[[NSUserDefaults standardUserDefaults] registerDefaults:dictionary];
}
(...)
and/or
(...)
[request setValue:@"Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0" forHTTPHeaderField:@"User-Agent"];
[webView loadRequest: request];
NSLog(@"Getting UA: %@", [webView stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"]);
(...)
but my output is:
Getting UA: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20130401 Firefox/31.0/Worklight/7.0.0.0
I tried to find this token somewhere in the configurations, but was unsuccessful...
I was able to reproduce this by adding the above code to the IBM Example, project "IncludeExternalPages". I'll be happy to provide the code if this helps.