react-nativetouch-idface-idpasscodeandroid-biometric

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


I am implementing biometric authentication for the application using react-native-fingerprint-scanner npm, with this npm I am not able to ensure that the device support biometric authentication or not, only for touch id is working for me.

How can I achieve Face Id, Passcode authentication ?

Verified using react-native-touch-id but it is not working for me.

Is there any way to achieve authentication on both platforms iOS and Android?

Reference:Link

enter image description here

enter image description here


Solution

  • 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);
      });