React Native Library to handle the biometric autentication. The library is developed with Turbomodules, for this reason to make it work is necessary use RN 0.68 or higher
npm install react-native-biometrics-scanner
or
yarn add react-native-biometrics-scanner
In your Info.plist:
<key>NSFaceIDUsageDescription</key>
<string>{Add here a message}</string>
In order to make it work you need to add the necessary Permissions in your AndroidManifest.xml:
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
import { getAvailableBiometric } from 'react-native-biometrics-scanner';
// ...
const result = await getAvailableBiometric();
This method return the type of biometric present on the device:
- iOS:
TouchID
orFaceID
- Android:
TouchID
orFaceID
orIrisID
or if it is not possible to retrieve any infoBiometricID
and throws:
UnknownBiometricError
when the status of biometric is unknownUnsupportedBiometricError
when the biometric is not supported by the deviceNoEnrollError
when user needs to enroll in order to use biometric
import { authenticate } from 'react-native-biometrics-scanner';
// ...
await authenticate(prompt);
It requires an object to configure the prompt message:
promptMessage
: the message to showallowDeviceCredentials
: if true the system fallback is used to authenticate after all the attempts of biometric fail, otherwiseBiometricFallbackError
is throwncancelButtonText
: the text for cancel button (Android only)(optional)descriptionText
: the text for description (Android only)(optional)subtitleText
: the text for subtitle (Android only)(optional)fallbackPromptMessage
: the title of fallback option (iOS only)(optional)
This method resolve a promise if the authentication is succesful and throws:
BiometricUnknownError
when the status of biometric is unknownBiometricUnsupportedError
when the biometric is not supported by the deviceBiometricNoEnrollError
when user needs to enroll in order to use biometricBiometricAuthenticationError
when the authentication failsBiometricUserCancelError
when user cancels the authenticationBiometricPasscodeNotSetError
when a passcode is not setBiometricLockOutError
when the device is lockedBiometricFallbackError
when the biometric authentication fails and a fallback has to be providedBiometricPasscodeNotSetError
when passcode is not setBiometricSystemCancelError
(iOS only) when the system cancels the authentication
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT