Adding Web Authentication (WebAuthn) Handling Support to Android WebView Apps

User login on screen

Modern-day web services and applications prioritize user security and convenience, and one of the technologies making waves in this department is Web Authentication (WebAuthn). It provides a secure and user-friendly way to authenticate users using biometrics, mobile devices, or FIDO security keys, eliminating the need for passwords. If you’re developing an Android WebView application, integrating WebAuthn might seem challenging, but it is absolutely doable.

However, before diving into the steps, it’s worth noting that if you use the WebViewGold app template, all this hard work is eliminated! WebViewGold comes with WebAuthn handling support out-of-the-box, making your WebView app development process smoother and more streamlined. But if you’re keen on adding this feature manually, let’s get started:

1. Update Your WebView Settings

Firstly, ensure you have set up a WebView in your Android app. To allow WebAuthn to function correctly, you need to adjust your WebView settings:

WebView myWebView = findViewById(;
WebSettings webSettings = myWebView.getSettings();

2. Handle WebViewClient & WebChromeClient

The WebAuthn API uses JavaScript, and sometimes it might require user interactions. Therefore, you need to set up both WebViewClient and WebChromeClient:

myWebView.setWebViewClient(new WebViewClient());
myWebView.setWebChromeClient(new WebChromeClient());

3. Permissions and Hardware Features

Make sure you’ve declared necessary permissions in your AndroidManifest.xml:

<uses-permission android:name="android.permission.USE_BIOMETRIC"/>
<uses-permission android:name="android.permission.USE_FINGERPRINT"/>
<uses-feature android:name="android.hardware.fingerprint" android:required="false"/>

Remember to handle permission requests at runtime too!

4. Handling WebAuthn JavaScript Calls

For particular WebAuthn calls, you might need to interface with Android’s biometric or security systems. This would involve overriding shouldOverrideUrlLoading or using JavaScript interfaces, depending on your implementation.

5. Testing

Ensure you thoroughly test WebAuthn functionalities. Different services might implement WebAuthn differently, so testing multiple services will give you confidence in your WebView app’s versatility.

Why Choose WebViewGold?

Adding WebAuthn support manually to your WebView app is undoubtedly an educational journey, but why go through this hassle when WebViewGold offers a ready solution? By choosing the WebViewGold app template, you benefit from:

  1. Out-of-the-box WebAuthn Support: No need for complex integrations or constant testing.
  2. Regular Updates: Stay updated with the latest web technologies without lifting a finger.
  3. Efficient Performance: WebViewGold is optimized for performance, ensuring your users have a smooth experience.
  4. Ready-to-use Features: From push notifications to offline mode, WebViewGold comes packed with features that can elevate your WebView app.

In conclusion, while adding WebAuthn to your Android WebView app manually can be a rewarding challenge, there’s a more efficient and straightforward solution with WebViewGold. If you prioritize user security, ease of use, and convenience, WebViewGold might just be your golden ticket.