Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: get original user agent. #94

Open
guylando opened this issue Mar 11, 2019 · 4 comments
Open

Feature request: get original user agent. #94

guylando opened this issue Mar 11, 2019 · 4 comments

Comments

@guylando
Copy link

guylando commented Mar 11, 2019

The browser user agent has a lot of information. If it was overriden by OverrideUserAgent cordova preference then there is no way to get the original user agent from javascript. It would be nice if this plugin would also have a property for the original user agent.

ios possible implementation

https://github.com/apache/cordova-ios/blob/master/CordovaLib/Classes/Public/CDVUserAgentUtil.m#L37

android possible implementation

String userAgent = System.getProperty( "http.agent" );

https://stackoverflow.com/questions/4103963/is-there-a-way-to-obtain-the-default-user-agent-string-aside-from-webview-getset/10248817#10248817

@renatoflorencia
Copy link

I would like this too, I had to use OverrideUserAgent to solve a login problem with google and after that the pieces of my code that verify the device through the plugin do not return the information of the device correctly anymore.

@guylando
Copy link
Author

@renatoflorencia hehe, same exact thing here with google login and to solve it I added the ability of getting original user agent in my custom cordova plugin

@andreszs
Copy link

andreszs commented Jun 28, 2024

That would be great. For the moment, navigator.userAgent retrieves the string, at least in android and browser platforms.

@breautek
Copy link
Contributor

String userAgent = System.getProperty( "http.agent" );

This wouldn't be the original user agent used by the webview. It would be the user agent used by the JVM. So I don't think this is a solution.

Android does have getDefaultUserAgent, this would be a proper solution I think.

I'm not sure if iOS has any equivalent API or even access to the user agent to store a reference.... and that would be a blocker. I believe iOS only has access to the custom user agent which will be nil until set. Ideally features should be implemented for all supported platforms. The https://github.com/apache/cordova-ios/blob/master/CordovaLib/Classes/Public/CDVUserAgentUtil.m#L37 link is broken, and I don't think CDVUserAgentUtil is something that ever existed.

That would be great. For the moment, navigator.userAgent retrieves the string, at least in android and browser platforms.

The JS navigator.userAgent will return the current (potentially overridden) user agent. Not the original one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants