【问题标题】:Expo authentication世博认证
【发布时间】: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


    【解决方案1】:
    const biometricAuth = await LocalAuthentication.authenticateAsync({
        promptMessage: 'Login With Biometrics',
        cancelLabel: 'Cancel',
        disableDeviceFallback: false,
      })
    
      if (biometricAuth.success) {
      // ======> Here for both biometric or pin/passcode based successful login .success object will be returned
        return true
      }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-08-29
      • 1970-01-01
      • 2019-08-09
      • 2018-07-12
      • 2019-11-11
      • 2019-03-25
      • 1970-01-01
      相关资源
      最近更新 更多