Biometric Auth Plugin
This plugin allows you to add an extra layer of security by requiring biometric authentication (fingerprint, face recognition) before granting access to your app.
All Premium Plugins are now available for free and open source to developers. Consider becoming Project Sponsor.
Secure, Non-Bypassable Gate
The authentication flow is designed to be a true security gate.
- Total UI Lock: When authentication is triggered, a full-screen overlay immediately blocks all app content. The native Toolbar and navigation drawer are also hidden and disabled.
- Guided Security Setup: If the user has no screen lock, they are prompted to set one up and are guided to the Android Security Settings.
- Persistent Lock: Resuming the app from the background will re-trigger authentication, preventing bypass.
Setup and Configuration
Enable Plugin: Ensure
BiometricPluginis listed in theplugins.enabledproperty inapp/src/main/assets/swv.properties.Configure Auth on Launch: To enable authentication every time the app starts, set the
biometric.trigger.launchproperty totrueinswv.properties.# In swv.properties plugins.enabled=BiometricPlugin,... # Require authentication every time the app starts or resumes. biometric.trigger.launch=trueIf
false(the default), authentication will only be triggered manually from your JavaScript.
Usage
Triggering Authentication from JavaScript
The plugin injects a window.Biometric object. You can call this to lock a specific feature or section of your app.
// Request biometric authentication
window.Biometric.authenticate();
Callbacks in JavaScript
Define callback functions to handle the result of the authentication attempt.
// Called on successful authentication
window.Biometric.onAuthSuccess = function() {
console.log("Authentication successful!");
};
// Called if there's an error (e.g., no hardware, lock screen not set up)
window.Biometric.onAuthError = function(errorMessage) {
console.error("Authentication error:", errorMessage);
};
// Called when the fingerprint/face is not recognized.
window.Biometric.onAuthFailed = function() {
console.warn("Authentication failed. Please try again.");
};