0.1.15 • Published 1 year ago

@kode-frontend/react-native-biometry-tools v0.1.15

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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

methoddescription
isSensorAvailablePromise return BiometryType if biometry is available and enrolled else throw error BiometryError
getSupportedBiometryTypePromise 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

0.1.15

1 year ago

0.1.14

2 years ago

0.1.13

2 years ago

0.1.11

2 years ago

0.1.10

2 years ago