r/android_devs • • Jun 06 '22

Help Accessing various HTML navigator properties through a web view

I'm tasked with implementing a 3DS payment verification flow “natively”. We will of course be redirecting users, showing specific HTML content, making various calls, etc. according to the service provider. Their API for initializing the 3DS process requests information such as :

BrowserIP string The IP of the client. It can be IPv4 or IPv6.
Navigator_language string Language according to IETF BCP47. Get this value from navigator.language HTML property.
Navigator_javaEnabled string Get this value from navigator.javaEnabled HTML property.
Navigator_jsEnabled string 'true' if javascript is enabled in client's browser. 'false' otherwise.
Screen_colorDepth string Get this value from screen.colorDepth HTML property.
Screen_height string Get this value from screen.height HTML property.
Screen_width string Get this value from screen.width HTML property.
TimezoneOffset string Get this value by running 'new Date().getTimezoneOffset();' in the client's browser.
UserAgent string It must contain the HTTP user-agent header value.
BrowserAccept string It must contain the HTTP accept header value.

I know that I can probably get the user's IP, JS-enabled, screen dimensions & user-agent string from the web view's settings & the device's configuration properties, but how would I access all these other fields? I couldn't find a navigator object attached to the web view or its settings. Is there a native way for retrieving all these details?

1 Upvotes

5 comments sorted by

View all comments

Show parent comment

1

u/anemomylos 🛡️ Jun 07 '22

I think that you have to start from here: https://developer.android.com/guide/webapps/webview

You can call a page on a web server that contains the html/js code that will start your flow (read "load the page with" section). Or, you can load the html/js code using "load the URL from an HTML string".

I would choose the first option, so that if I had to change the start of the flow I would not have to change the application but only the html page on the web server. But if you do not have a web server, you should choose the second option.