I want to modify the user agent string in a WebView so that on the server side I can detect that the request has come from my react-native app. I want to do this using the sourc
For Android, you only need to set userAgent
attribute, for example:
For iOS, you need to add the code below inside the method didFinishLaunchingWithOptions
(before the line return YES;
) in AppDelegate.m
implementation:
NSString *userAgent = @"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36";
NSDictionary *dictionary = [[NSDictionary alloc] initWithObjectsAndKeys:userAgent, @"UserAgent", nil];
[[NSUserDefaults standardUserDefaults] registerDefaults:dictionary];