我需要你在反应本地人方面的专业知识。
我正在尝试为我的应用程序使用expo-local-authentication进行本地指纹身份验证。我的项目是使用expo init命令创建的。
我已经按照文档完成了设置,但仍然遇到了一个奇怪的问题:下面是我面临的LocalAuthentication.authenticateAsync(options)错误
本机方法ExpoLocalAuthentication.authenticateAsync需要0的参数,但接收到1
下面是我的代码所需的部分:
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(),但它仍然抛出相同的错误。
对于什么可能是问题的根本原因以及我如何解决它或任何其他本地身份验证的替代方案,我们将不胜感激。
发布于 2020-08-14 19:07:31
将您的应用程序更新到最新版本的expo (在我的例子中是38)和最新版本的expo-local-authentication,错误就会消失。
https://stackoverflow.com/questions/62993596
复制相似问题