Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70612

Override the user agent sent with Http requests

$
0
0

@sindri wrote:

Hello,

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/%@",
originalUserAgent,CDV_VERSION,
[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"]];

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70612

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>