Skip to content

Instantly share code, notes, and snippets.

@bnlokash
bnlokash / biometrics-provider.tsx
Last active June 26, 2024 11:22
React Native Biometrics Hook
import React, { createContext, useState, useEffect, FC, useContext } from 'react'
import Keychain from 'react-native-keychain'
import AsyncStorage from '@react-native-async-storage/async-storage'
interface IBiometricsContext {
isBiometricsSupported: boolean
isBiometricsEnabled: boolean
isBiometricsLoading: boolean
biometricsType: Keychain.BIOMETRY_TYPE | null
enableBiometrics: (username: string; password: string) => Promise<void>