@kode-frontend/react-native-biometry-tools
TypeScript icon, indicating that this package has built-in type declarations

0.1.15 • Public • Published

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

Package Sidebar

Install

npm i @kode-frontend/react-native-biometry-tools

Weekly Downloads

495

Version

0.1.15

License

MIT

Unpacked Size

31.9 kB

Total Files

17

Last publish

Collaborators

  • kode-frontend