android - 限制用户进行特定类型的生物特征认证?
问题描述
嘿, 我想开发一个应用程序,其中用户首先被限制进行指纹认证,指纹认证后,用户将被限制为面部识别认证。但是当我使用 Local_auth.authenticate 时,它为用户提供了想要扫描指纹或面部 ID 的选项,我该如何解决这个问题。
解决方案
你可以试试下面的代码:
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()));
}
}
推荐阅读
- r - 如何在 R 脚本中调用 Windows 终端?
- ios - 即使我已经配置了 Firebase 也没有配置它
- python-2.7 - 如何从 unicode 字符串中删除前缀 u?
- mysql - MySQL JOIN 来自另一个表的值基于该表中原始表的(重复)值
- python - Python 输入包含 NaN、无穷大或对于 dtype float32 而言太大的值
- php - Mysql 和 PHP 选择 Join Count
- firebase - 如何限制 Firebase 存储的下载次数?
- syslog-ng - 使用非文件目标的模板修改消息格式
- python - 有什么理由将导入库作为类属性?
- android - What is the full list of extras for Intent.ACTION_PICK?