I have an app in which I have different web views for different flows (which are being managed by different teams). My problem is that I want to set different user agents for different flows, ie. User-Agent = "XYZ" for some flow and User-Agent = "ABC" for some other flow.
I have tried using the following code, after reading from some StackOverflow links, before I init the controller containing UIWebView, but I read somewhere that I cannot modify User-Agent this way.
- (void)setUserAgentForWebView
{
UIWebView *dummyWebView = [[UIWebView alloc] initWithFrame:CGRectZero];
NSString *secretAgent = [dummyWebView stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"];
NSString *newUserAgent = [NSString stringWithFormat:@"%@/IPHONE_V3",secretAgent];
NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:newUserAgent, @"UserAgent", nil];
[[NSUserDefaults standardUserDefaults] registerDefaults:dictionary];
[[NSUserDefaults standardUserDefaults] synchronize];
}
I use this code to set different User-Agent for different flows according to my need. But it seems that User-Agent is not modified because I can't get desired results.
Kindly guide me on this.