How it works
- Check biometric availability: First, check whether biometric authentication data is available and biometrics are supported for the device (older models or MDM configurations may disable the support). If no fingerprints or Face ID are set up, do not display the biometric sign-in prompt.
- Save sign-in secret: After a user signs in and biometric authentication is available, the website can save a secret using the plugin. The secret is stored in the iOS Keychain, which uses cryptographic hardware to ensure it cannot be retrieved without biometric authentication. Saving the secret does not require user interaction.
- Retrieve saved secret: On future visits, if a saved secret is available, the site can prompt the user to authenticate via fingerprint (Touch ID) or Face ID. If authentication succeeds, the secret is returned via the JavaScript callback. If it fails, an error is returned.
- Use secret to sign in: Once the secret is recovered, you can either use it to sign in the user directly or populate the login form on your web app.
Developer DemoDisplay our demo page in your app with the Face ID / Touch ID Native Plugin active to test during development https://median.dev/auth/
Implementation guide
This guide assumes a working publicly-accessible website (or test site) with a username and password login system.Save secret on successful login
After a user successfully signs in to your website with their username and password, check to see if Touch ID is available. If it is, save a secret for future retrieval. The secret must be a single string and can be a combination of the username and password, or an authentication token. For example, you may embed this JavaScript into your post-login page:Check for secret on login page
On the login page, you will need to know whether or not to prompt for Touch ID credentials. Start by getting the status:median_secret_callback function is called with the previously saved secret, it should perform a request to sign in the user. If the credentials are incorrect, you should delete the secret and allow manual sign-in by running the function:
Median JavaScript Bridge reference
Retrieving Face ID / Touch ID availability
Run the JavaScript function:hasTouchId:trueorfalse. Indicates if the device is running iOS 9+ and there are fingerprints enrolled, or Face ID is enabled.biometryType:'touchId','faceId', or'none'. This field is populated on iOS only to differentiate between Touch ID and Face ID.hasSecret:trueorfalse
Saving a secret
Typically you will want to first check that Face ID / Touch ID is available via the status function above and then save the secret. Run the JavaScript function:callbackFunction is optional and will be called after the save operation with a success parameter.
Retrieving a secret
Run the JavaScript function:success:trueorfalseerror: provided success isfalse(see error codes below)secret: the previously stored secret
callbackOnCancel. If set to 1 and the user cancels the authentication, the callback will be run with success=false, error=userCanceled. If callbackOnCancel is not set (or set to 0), the callback will not be run.
Delete a secret
Run the JavaScript function:success: true or falseerror: provided if success is false
Possible error values
In general, you will only need to handleauthenticationFailed in the “get secret” request.
duplicateItem: Secret already existsitemNotFound: No secret savedauthenticationFailed: Biometric check failedgenericError: Unexpected failureuserCanceled: User canceled the auth promptunimplemented: Plugin not supported
Testing Face ID / Touch ID integration
We recommend testing on physical devices to confirm the flow is working as expected for devices with Face ID / Touch ID support, as well as older models or more restricted device configurations. Additionally, you can also test the integration using the Appetize Simulators.- Open the demo page in the simulator
- Click the Face ID Button (as shown below) to enable biometrics support in the simulator
- Sign in with credentials
- Return to the demo page and use the Login with Face ID or Login with Touch ID button without having to provide username and password again

Appetize: Face ID button
Whitelist domains for plugin access
By default, any page loaded in your app will be able to use Median JavaScript Bridge to retrieve secrets. If you are allowing any domains you do not control to be loaded within your app (see Link Handling), we strongly recommend whitelisting only certain domains. To do so, go to the Native Plugins tab in App Studio, click Settings for the Face ID/TouchID Android Biometrics plugin and add your whitelisted URLs as shown below. Regular expressions are supported to allow wildcards in the URL.
Whitelisting URLs for access