问题
I have implemented react-native-fingerprint-scanner
in my application its working fine for Touch Id
.
Now I wanted to add authentication for Touch ID, Face Id, Pass code for both platform
Is there any to check whether your device support or not respectively it will ask for lock pattern
?
Also I have tried using react-native-touch-id
but it is not working me for Face Id
Is there any way to achieve this for both platform (iOS/android)?
Reference:Link
回答1:
react-native-touch-id
should work for both TouchID and FaceID.
iOS allows the device to fall back to using the passcode, if faceid/touch is not available. this does not mean that if touchid/faceid fails the first few times it will revert to passcode, rather that if the former are not enrolled, then it will use the passcode.
from the docs
You can check to see if its supported first.
const optionalConfigObject = {
fallbackLabel: 'Show Passcode',
passcodeFallback: true,
}
TouchID.isSupported(optionalConfigObject)
.then(biometryType => {
// Success code
if (biometryType === 'FaceID') {
console.log('FaceID is supported.');
} else {
console.log('TouchID is supported.');
}
})
.catch(error => {
// Failure code
console.log(error);
});
来源:https://stackoverflow.com/questions/58218710/how-to-programmatically-check-support-of-touch-id-face-id-password-and-pattern