首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >but本机:本机方法ExpoLocalAuthentication.authenticateAsync需要0的参数,但接收到1

but本机:本机方法ExpoLocalAuthentication.authenticateAsync需要0的参数,但接收到1
EN

Stack Overflow用户
提问于 2020-07-20 10:38:48
回答 1查看 833关注 0票数 1

我需要你在反应本地人方面的专业知识。

我正在尝试为我的应用程序使用expo-local-authentication进行本地指纹身份验证。我的项目是使用expo init命令创建的。

我已经按照文档完成了设置,但仍然遇到了一个奇怪的问题:下面是我面临的LocalAuthentication.authenticateAsync(options)错误

本机方法ExpoLocalAuthentication.authenticateAsync需要0的参数,但接收到1

下面是我的代码所需的部分:

代码语言:javascript
复制
import * as LocalAuthentication from 'expo-local-authentication';

const authenticate = async () => {
    const hasHardwareAsync = await LocalAuthentication.hasHardwareAsync();

    if (hasHardwareAsync) {
      const supportedAuthentications = await LocalAuthentication.supportedAuthenticationTypesAsync();

      if (supportedAuthentications.indexOf(1) !== -1) {
        // Finger print supported
        const isFingerprintEnrolled = await LocalAuthentication.isEnrolledAsync();

        if (isFingerprintEnrolled) {
          const options = {
            promptMessage: 'Authenticate yourself',
          };
          try {
            // Also tried with await but it throws the same error 
            // await LocalAuthentication.authenticateAsync(options)
            
            LocalAuthentication.authenticateAsync(options).then(result => {
              // I never get inside this block
              console.warn(result)
            })
            .catch(error => {
              console.warn('Authentication Error: ', error)
            })
          } catch (error) {
            console.warn(error)
          }
        }
      }
    }
  }

不知道我错过了什么。似乎没有关于错误的可用信息。我还试图在没有任何参数的情况下运行LocalAuthentication.authenticateAsync(),但它仍然抛出相同的错误。

对于什么可能是问题的根本原因以及我如何解决它或任何其他本地身份验证的替代方案,我们将不胜感激。

EN

回答 1

Stack Overflow用户

发布于 2020-08-14 19:07:31

将您的应用程序更新到最新版本的expo (在我的例子中是38)和最新版本的expo-local-authentication,错误就会消失。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62993596

复制
相关文章

相似问题

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