Biometric Authentication

Secure Apps With Devices Touch Id or Face Id

You'll need to import the javascript file in your website before starting from this link.

This module explains the ways to use the Biometric authentication functions where you can use the devices Touch/Face Id to unlock an app or use it to secure pages.

If you have choose to handle biometric by yourself then following js apis will be required.

Show Biometric option

Use following code to show biometric in the app. If it is authenticated successfully then callback function will be called.

window.WTN.Biometric.show({
    prompt:"Authenticate to continue!",
    callback:function(data){
        /* data returns the object below 
        {
            isSuccess: true,
            secret: 'saved secret token'
        }
        */
        
    }
});
Prompt - Used to show text to user when aithentication prompt is shown.

Callback - function called on user authenticating or cancelling the promt.

Save secret

Use following code to save secret in the app. This secret will be returned when you show the biometric when user opens the app. Secret can be used for example to store a login token, using that token you can handle custom handling like get the user logged in.

window.WTN.Biometric.saveSecret({
    secret:"send secret token here",
    callback:function(data){
        /* data returns the object in below format
        
        {
           isSuccess: true
        }
        */
    }
});

Delete Secret

Use following code to delete secret in the app.

window.WTN.Biometric.deleteSecret({
    callback:function(data){
        /* data returns the object below 
        {
            isSuccess: true
        }
        */
    }
});

Check Status

Check status function will return if biometric is active.

window.WTN.Biometric.checkStatus({
    callback:function(data){
        /* data returns the object below */
        {
            isSuccess: true,
            hasTouchId: true,
            hasSecret: true/false
        }
    }
});

Last updated