首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >flutter localauth :未启用必需的安全功能

flutter localauth :未启用必需的安全功能
EN

Stack Overflow用户
提问于 2021-04-10 03:48:04
回答 2查看 285关注 0票数 1

我正在使用local_auth:^1.1.3并使用

代码语言:javascript
复制
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方法时,我得到了这个错误:

代码语言:javascript
复制
PlatformException(NotAvailable, Required security features not enabled, null, null) 

我想,当用户没有在手机上配置指纹时,当点击身份验证按钮时,默认的生物识别对话框打开,用户可以在手机上进行配置,但我得到了这个错误。它应该打开默认的生物识别对话框来将用户转移到手机的配置部分,但我得到了错误。

我还在manifest中添加了<uses-permission android:name="android.permission.USE_BIOMETRIC"/>

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

代码语言:javascript
复制
environment:
  sdk: ">=2.12.0 <3.0.0"
EN

Stack Overflow用户

发布于 2021-09-30 09:05:15

我通过捕获PlatformException异常并在调用authenticate()方法之前检查canCheckBiometricsisDeviceSupported()解决了这个问题。

这是一段代码:

代码语言:javascript
复制
if (await auth.canCheckBiometrics && await auth.isDeviceSupported()){
    try {
        if(await auth.authenticate(
          ... // authenticate configuration
           )){
               // authenticated
        }
      } on PlatformException catch (exception) {
        // catch the exception
      }
    }
票数 0
EN
查看全部 2 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67027420

复制
相关文章

相似问题

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