Closed bbroereES closed 5 years ago
verifyFingerprint() {
this._fingerprintAuth = new FingerprintAuth();
return new Promise((resolve, reject) => {
this._fingerprintAuth
.available()
.then(result => {
console.log('Biometry result', result);
// the result is an object so check the values
if (result.any) {
// we can use the face or touch ID here YAY
this._fingerprintAuth
.verifyFingerprint({
title: 'Android title', // optional title (used only on Android)
message: `Verify your identity to access your account.`,
authenticationValidityDuration: 1,
useCustomAndroidUI: false
})
.then(verifyResult => {
console.log(`Verify Fingerprint result`, verifyResult);
resolve();
})
.catch(err => {
console.log(`Verify Fingerprint error`, err);
reject();
});
} else {
if (isIOS) {
// check if Biometry is locked out.
const laContext = LAContext.new();
laContext.evaluatePolicyLocalizedReasonReply(
LAPolicy.DeviceOwnerAuthentication,
'test',
(ok: boolean, error: NSError) => {
if (!ok) {
console.log(error.code, error.localizedDescription, '\n\n\n\n\n');
if (error.code === LAError.BiometryLockout) {
console.log(
`Biometry is locked out. How do we want to handle this scenario? User must enter passcode to enable Biometry.`,
);
} else if (error.code === LAError.UserCancel) {
console.log(`The user tapped the cancel button in the authentication dialog.`);
reject();
}
resolve();
} else {
resolve(ok);
}
},
);
} else if (isAndroid) {
resolve();
}
}
})
.catch(err => {
console.log('Fingerprint available error', err);
});
});
}
I have this working in an Angular project currently with the latest version of the plugin.
In my Angular integration 'verifyFingerprint' does not work on iOS and Android. However, 'verifyFingerprintWithcustomfallback' seems to work fine.
Problem: When using verifyFingerprint, the popup is not shown but immediately rejected. I should mention that I have a nativescript angular shared project.