我正在使用local_auth:^1.1.3并使用
await _localAuthentication.authenticate(
localizedReason: S.of(Get.context!).main_pass_view_body,
// "Please authenticate to complete your transaction",
androidAuthStrings: androidMessages,
iOSAuthStrings: iosMessages,
useErrorDialogs: true,
stickyAuth: true);但是当我调用authenticate方法时,我得到了这个错误:
PlatformException(NotAvailable, Required security features not enabled, null, null) 我想,当用户没有在手机上配置指纹时,当点击身份验证按钮时,默认的生物识别对话框打开,用户可以在手机上进行配置,但我得到了这个错误。它应该打开默认的生物识别对话框来将用户转移到手机的配置部分,但我得到了错误。
我还在manifest中添加了<uses-permission android:name="android.permission.USE_BIOMETRIC"/>。
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.0.4, on Linux, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.0-rc1)
[✓] Chrome - develop for the web
[!] Android Studio (not installed)
[✓] VS Code (version 1.55.1)
[✓] Connected device (2 available)
! Doctor found issues in 1 category.和flutter sdk
environment:
sdk: ">=2.12.0 <3.0.0"发布于 2021-09-30 09:05:15
我通过捕获PlatformException异常并在调用authenticate()方法之前检查canCheckBiometrics和isDeviceSupported()解决了这个问题。
这是一段代码:
if (await auth.canCheckBiometrics && await auth.isDeviceSupported()){
try {
if(await auth.authenticate(
... // authenticate configuration
)){
// authenticated
}
} on PlatformException catch (exception) {
// catch the exception
}
}https://stackoverflow.com/questions/67027420
复制相似问题