【问题标题】:Restrict user for specific type of Biometric Authentication?限制用户进行特定类型的生物特征认证?
【发布时间】:2021-11-16 13:47:59
【问题描述】:

喂, 我想开发一个应用程序,首先限制用户进行指纹认证,指纹认证后,用户将被限制为面部识别认证。 但是,当我使用 Local_auth.authenticate 时,它​​为用户提供了想要扫描指纹或面部 ID 的选项,我该如何解决这个问题。

【问题讨论】:

  • iOS 设备具有指纹或面部识别功能。不是两者都
  • 是的,如果设备不支持任何类型的生物识别,则应用不会要求这样做。
  • 你应该删除 iOS 标签,因为这个问题对 iOS 没有意义
  • 请提供足够的代码,以便其他人更好地理解或重现问题。

标签: android flutter android-studio localauthentication


【解决方案1】:

你可以试试下面的代码:

Future<void> _authenticateMe() async {
// 8. this method opens a dialog for fingerprint authentication.
//    we do not need to create a dialog nut it popsup from device natively.
bool authenticated = false;
try {
  authenticated = await _localAuthentication.authenticateWithBiometrics(
    localizedReason: "Authenticate for Testing", // message for dialog
    useErrorDialogs: true,// show error in dialog
    stickyAuth: true,// native process

  );
  print('support device try: '+authenticated.toString());
} catch (e) {
  print('support device catch: '+e.toString());
  print(e);
}
if (!mounted) return;
setState(() {
  _authorizedOrNot = authenticated ? "Authorized" : "Not Authorized";
});

if(_authorizedOrNot == 'Authorized'){
  Navigator.of(context).push(MaterialPageRoute(builder: (context) => HomeScreen()));
}

}

【讨论】:

  • 我已经尝试了给定的代码,但在身份验证时,它为用户提供了想要使用指纹或面部 ID 进行身份验证的选项。
  • 指纹专用
猜你喜欢
  • 1970-01-01
  • 2020-09-29
  • 1970-01-01
  • 2020-04-19
  • 1970-01-01
  • 2016-02-18
  • 1970-01-01
  • 1970-01-01
  • 2015-12-21
相关资源
最近更新 更多