android - Flutter、local_auth:Face ID 认证不起作用(即使可用)
问题描述
我需要在颤振应用程序中实现人脸 ID(生物识别)身份验证。我正在使用颤振包“local_auth”v1.1.6(https://pub.dev/packages/local_auth)。但是,当在所需设备上运行时,人脸验证选项在应用程序中不可用。
我正在使用以下功能,该功能在按下按钮时运行:
Future<bool> authenticate() async {
try {
final canCheckBiometrics = await _auth.canCheckBiometrics;
print('canCheckBiometrics: ');
print(canCheckBiometrics);
final availableBiometrics = await _auth.getAvailableBiometrics();
print('getAvailableBiometrics: ');
print(availableBiometrics);
return await _auth.authenticate(
localizedReason: 'Authenticate',
biometricOnly: true,
);
} on PlatformException catch (e) {
print(e);
rethrow;
}
}
但是,面部身份验证永远不会显示为可用的身份验证选项,即使它被列为“可用的生物特征”:
I/flutter ( 4816): canCheckBiometrics:
I/flutter ( 4816): true
I/flutter ( 4816): getAvailableBiometrics:
I/flutter ( 4816): [BiometricType.fingerprint, BiometricType.face]
如果设备上同时设置了指纹和面部,则指纹显示为唯一可用的身份验证选项。如果只设置了 face,则 local_auth 库会抛出“NotEnrolled”异常(如果没有设置任何方法,则相同):
I/flutter ( 4816): canCheckBiometrics:
I/flutter ( 4816): true
I/flutter ( 4816): getAvailableBiometrics:
I/flutter ( 4816): [BiometricType.fingerprint, BiometricType.face]
I/flutter ( 4816): PlatformException(NotEnrolled, No biometrics enrolled on this device., null, null)
为了运行该应用程序,我使用的是搭载 Android 10 的 ULEFONE ARMOR X7 手机 - 它同时具有指纹和人脸 ID 身份验证功能,两者都可用于解锁设备屏幕 - 即使只设置了面部,它也可用于解锁屏幕,但它在应用程序中不可用。
有什么方法可以在这款手机上启用 Face ID 身份验证吗?对我来说,让它专门在这个设备上工作是很重要的。
解决方案
推荐阅读
- javascript - react-virtualized 网格从服务中检索图像,但直到滚动操作才呈现
- jquery - 使用引导表期间的详细视图不起作用
- authentication - asp.Net core 2.2中的多种身份验证方法
- scala - 火花数据集的问题
- sass - 将参数列表传递给 sass mixin 并从中组合一个值
- java - 具有地图属性的实体的休眠查询
- hive - 如何处理 hive 中的嵌入式逗号?
- bash - 将变量设置为curl输出时退出bash脚本
- javascript - FancyBox - 使用 iframe 的箭头/导航
- windows-7 - ollydbg 中的入口点不是根据 PE 中的 ImageBase 值