A way to detect Biometry type for Android/iOS devices
FarjadGov14 opened this issue · 0 comments
FarjadGov14 commented
Description of feature / user story
A great feature to add would be to detect biometry type for Android/iOS devices, by using this below library
react-native-biometrics
If we can create a service or a utility in bifold to detect Biometry type we can guide the users accordingly, a utility function that can be used in a context provider and used by wallets to enhance User experience.
A Sample code that we could use below:
import Biometry, { BiometryType } from 'react-native-biometrics'
export interface IsSensorAvailableResult {
available: boolean
biometryType?: BiometryType
error?: string
}
export interface SimplePromptResult {
success: boolean
error?: string
}
export function serviceGetBiometryDescription(biometryType: BiometryType | undefined): string {
switch (biometryType) {
case Biometry.TouchID:
return Biometry.TouchID
case Biometry.FaceID:
return Biometry.FaceID
case 'Biometrics':
return 'Biometrics'
default:
throw new Error('We do not support this type of biometry')
}
}
export function serviceAuthenticateWithBiometrics(promptMessage: string): Promise<SimplePromptResult> {
return Biometry.simplePrompt({
promptMessage: promptMessage,
})
}
export function serviceGetEnrolledBiometry(): Promise<IsSensorAvailableResult> {
return Biometry.isSensorAvailable()
}
export async function biometryType(): Promise<BiometryType | undefined> {
let biometryType: BiometryType | undefined
await Biometry.isSensorAvailable().then((resultObject) => {
biometryType = resultObject.biometryType
})
return biometryType
}
This can be used across different wallets as a utility service.
Acceptance Criteria
A Hook for biometryType that can detect the device type and it can be used by other wallets as a custom hook.