Override the user agent sent with Http requests


I’m trying to override the User-Agent string that is sent with HTTP requests. I have managed to solve the problem for iOS but unable to find a solution that works for Android. I have tried to add to my config.xml without any luck.

<preference name="OverrideUserAgent" value="Mozilla/5.0 My Browser" />

Is there any way to do this either in ionic or in the Android project?

BTW the solution that worked on iOS is as following from here :

UIWebView* sampleWebView = [[UIWebView alloc] initWithFrame:CGRectZero];
NSString* originalUserAgent = [sampleWebView stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"];
    self.viewController.baseUserAgent = [NSString stringWithFormat:@"%@ customAgent/%@ customAgent/%@",
[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"]];