javascriptreact-nativeexpobiometrics

TypeError: null is not an object (evaluating 'bridge.isSensorAvailable')


react-native-biometrics npm package for biometric authentication.

Exporting as module would not work both with IOS & Android emulators and Updated Android OS smartphone. Tried the package versions 2.1.4 and 3.0.1. Dependencies checked.

Based on this code snippet from the README. (other biometric npm packages worked in similar way, excluding wrong export implementation or biometric specific issues).

import ReactNativeBiometrics from 'react-native-biometrics'

ReactNativeBiometrics.isSensorAvailable()
  .then((resultObject) => {
    const { available, biometryType } = resultObject

    if (available && biometryType === ReactNativeBiometrics.TouchID) {
      console.log('TouchID is supported')
    } else if (available && biometryType === ReactNativeBiometrics.FaceID) {
      console.log('FaceID is supported')
    } else if (available && biometryType === ReactNativeBiometrics.Biometrics) {
      console.log('Biometrics is supported')
    } else {
      console.log('Biometrics not supported')
    }
  })

If it is a common issue and there is an alternative expo solution for generating cryptographic keys other than local auth, this might help me and others as well.


Solution

  • NativeModules (usually ones that access hardware) packages can't be used with expo managed projects, but only with bare workflow. managed-vs-bare.

    Looking for a result based biometric solution of either kind:

    1. Make this lib work.
    2. Alternative for react native.

    I found an alternative that is even more broadly in use and for some reason initially missed it.

    npm package - react-native-keychain Should be for non expo managed projects. But didn't work as well.

    Alternatives for expo managed solution - use expo-secure-store and expo-local-authentication