-
Notifications
You must be signed in to change notification settings - Fork 47
Send correct User-Agent header #10
Comments
Sorry for not being precise. |
Cordova has a preference "OverrideUserAgent". |
Ok gotcha, I'll look into it |
Thank you! This will be a lifesaver for us. |
I believe I need to add something like this, can't test right now.. If you want to clone add/test these lines in
|
I'm getting the error: and then I tried to hardcode custom string, but new error:
I'm not familiar with iOS native development so can't really help here. |
Sorry, meant to be
cdvwkStringForKey vs cordovaSettingForKey |
Now it's building fine. But User-Agent header is still being overwritten. This code most likely set the header on webview level and not on iOS native level. We need to set it on native level or set it with each http requests. |
Ok I'd have to spend some time on it, can't do it right now |
I have made it working by adding following code in line 385:
Not sure about weakWebView.customUserAgent I wasn't able to get it from wkWebView.configuration.preferences or maybe it's same. With that combination I get expected results. |
It would be cool to avoid usage of cordova-plugin-useragent and combine the code to get navigator.userAgent and set it to User-Agent header of the request. |
Please test 1.1.0 using CustomUserAgent flag (see updated readme) |
It works fine with that flag. Thanks! But then the User-Agent is all the time same for all devices (hardcoded). |
or event better to introduce one more boolean flag "UseDefaultUserAgent" or "UseWebViewUserAgent". If set to true than use the value from navigator.userAgent. This approach will keep existing behavior but introduce the option we are looking for. I strongly believe this could help others as well. |
No can't do that because other plugins/objects can rely on the user agent to catch if it is running on iOS/Android etc. Also this is a XHR plugin so I will keep it related to XHR requests without tempering with the webview too much. This is as far as I will take it but feel free to fork and make your own modifications. |
Ok, I understand. |
Hello,
Using this plugin all requests comes with native iOS User-Agent header.
The header looks similar to this: "appName/3.0.10 CFNetwork/978.0.7 Darwin/18.7.0"
Expected value should be like this: "Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0 Mobile/15E148 Safari/604.1"
I see that all ajax calls send correct header, but in backend we get that iOS specific one. This is currently a problem to Authenticate with Microsoft Azure where conditional access policy enabled to check the device model. It simply can't recognize the device.
Could that be fixed?
Thank you!
The text was updated successfully, but these errors were encountered: