How to check support of Touch ID, Face Id ,Passwor

2020-04-04 02:22发布

I have implemented a react-native-fingerprint-scanner, it's working for Touch Id.

Now I wanted to add authentication for Touch ID, Face Id, Passcode for both platform

Is there any way to check whether your device support or not. Also, I have tried using react-native-touch-id but it is not for Face Id on android.

Is there any way to achieve this for both platforms (iOS/Android)?

Reference:Link

enter image description here

enter image description here

1条回答
做个烂人
2楼-- · 2020-04-04 02:43

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);
  });
查看更多
登录 后发表回答