【发布时间】:2022-07-15 23:50:19
【问题描述】:
我目前正在使用 expo 身份验证来设置生物特征,它目前正在工作,但后备选项是使用手机 PIN,但我不知道如何捕获我的 PIN 码是否成功,我在哪里可以捕获react native 中的 pin 成功消息?
在下面查看我的代码
import * as LocalAuthentication from 'expo-local-authentication'
export const handleBiometricAuth = async () => {
const isBiometricAvailable = await LocalAuthentication.hasHardwareAsync()
if (!isBiometricAvailable) {
Alert.alert('Please, enter your pin', 'biometric auth not supported', [
{
text: 'ok',
onPress: () => console.log('fallback'),
},
])
return false
}
const savedBiometrics = await LocalAuthentication.isEnrolledAsync()
if (!savedBiometrics) {
Alert.alert('Attention', 'You should enable your biometrics or pin ', [
{
text: 'ok',
onPress: () => console.log('fallback'),
},
])
return false
}
const biometricAuth = await LocalAuthentication.authenticateAsync({
promptMessage: 'Login With Biometrics',
// cancelLabel: 'Cancel',
// disableDeviceFallback: true,
})
if (biometricAuth.success) {
return true
}
return false
}```
【问题讨论】:
标签: android reactjs react-native authentication expo