How to programmatically check support of Touch ID, Face Id ,Password and pattern lock in React-Native

柔情痞子 提交于 2019-12-23 09:35:29

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!