@kode-frontend/react-native-biometry-tools
v0.1.15
Published
Tools and helpers for biometry
Downloads
612
Maintainers
Readme
react-native-biometry-tools
A lightweight library for determining the supported type of biometrics.
Motivation
The react-native-keychain does not allow you to determine the type of biometrics supported by the device if it is not registered.
Installation
yarn add @kode-frontend/react-native-biometry-tools
Usage
import BiometryTools from '@kode-frontend/react-native-biometry-tools';
export default function App() {
React.useEffect(() => {
BiometryTools
.isSensorAvailable()
.then((biometryType) => {
// sensor available
// biometryType - supported biometry
})
.catch((e) => {
// sensor not available
// biometry not supported or not enrolled
console.log(e.message)
console.log(e.code)
})
BiometryTools
.getSupportedBiometryType()
.then((biometryType) => {
// even if biometry not enrolled
// biometryType - supported biometry, if biometry not supported then return null
})
}, []);
return (
<View />
);
}
Available methods
| method | description |
| ------------------------ | ------------------------------------------------------------------------------------------------------- |
| isSensorAvailable | Promise return BiometryType
if biometry is available and enrolled else throw error BiometryError
|
| getSupportedBiometryType | Promise return BiometryType
if biometry is supported else return null
even if biometry not enrolled |
Types
enum BiometryType {
// ios only
FACE_ID = 'Face ID',
TOUCH_ID = 'Touch ID',
// android only
FINGERPRINT = 'Fingerprint',
FACE = 'Face',
IRIS = 'Iris'
}
enum BiometryErrorCode {
// common
NOT_SUPPORTED = 'BiometryScannerNotSupported',
NOT_ENROLLED = 'BiometryScannerNotEnrolled',
// ios only
NOT_AVAILABLE = 'BiometryScannerNotAvailable',
PASSCODE_NOT_SET = 'PasscodeNotSet',
DEVICE_LOCKED_PERMANENT = 'DeviceLockedPermanent'
}
Tags
release
- create release tag and increase version