Links
Comment on page

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.
Plain JS
ES 6+
window.WTN.Biometric.show({
prompt:"Authenticate to continue!",
callback:function(data){
/* data returns the object below
{
isSuccess: true,
secret: 'saved secret token'
}
*/
}
});
import Biometric from "webtonative/Biometric";
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.
Biometric Auth Screen

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.
Plain JS
ES 6+
window.WTN.Biometric.saveSecret({
secret:"send secret token here",
callback:function(data){
/* data returns the object in below format
{
isSuccess: true
}
*/
}
});
import Biometric from "webtonative/Biometric";
Biometric.saveSecret({
secret:"send secret token here",
callback:function(data){
/* data returns the object in below format
{
success: true
}
*/
}
});

Delete Secret

Use following code to delete secret in the app.
Plain JS
ES 6+
window.WTN.Biometric.deleteSecret({
callback:function(data){
/* data returns the object below
{
isSuccess: true
}
*/
}
});
import Biometric from "webtonative/Biometric";
Biometric.deleteSecret({
callback:function(data){
/* data returns the object below
{
success: true
}
*/
}
});

Check Status

Check status function will return if biometric is active.
Plain JS
ES 6+
window.WTN.Biometric.checkStatus({
callback:function(data){
/* data returns the object below */
{
isSuccess: true,
hasTouchId: true,
hasSecret: true/false
}
}
});
import Biometric from "webtonative/Biometric";
Biometric.checkStatus({
callback:function(data){
console.log("Function called",data);
}
});