首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >世博认证

世博认证
EN

Stack Overflow用户
提问于 2022-03-01 11:24:43
回答 1查看 277关注 0票数 1

我目前正在使用世博认证来设置生物识别技术,到目前为止,它还在工作,但后备选项是使用手机PIN,但我不知道如何捕获我的密码是否成功,我在哪里可以捕获密码成功消息的反应本机?

见下面的代码

代码语言:javascript
复制
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
}```
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-07-15 15:50:19

代码语言:javascript
复制
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
  }
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71307744

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档