[英]local_auth iOS (Flutter)
Flutter local_auth didn't return platform exception when biometrics and passcode are disable for iOS. Flutter 当为 iOS 禁用生物识别和密码时,local_auth 没有返回平台异常。
I have a functionality where if biometrics and passcode are disable, I will use another function for authentication but it only works on Android and didn't work on iOS.我有一个功能,如果生物识别和密码被禁用,我将使用另一个 function 进行身份验证,但它只适用于 Android 而不适用于 iOS。
Future<bool> authentication() async {
try {
return await _localAuthentication.authenticate(
localizedReason: Strings.localAuthReason,
useErrorDialogs: true,
stickyAuth: true,
);
} on PlatformException {
return false;
}
}
import this code below import 'package:local_auth/error_codes.dart' as local_auth_error;导入下面的代码 import 'package:local_auth/error_codes.dart' as local_auth_error;
and try this试试这个
Future<bool> authentication() async {
try {
return await _localAuthentication.authenticate(
localizedReason: Strings.localAuthReason,
useErrorDialogs: true,
stickyAuth: true,
);
} on PlatformException catch (exception) {
if (exception.code == local_auth_error.notAvailable ||
exception.code == local_auth_error.passcodeNotSet ||
exception.code == local_auth_error.notEnrolled) {
// Handle this exception here.
}
}
} }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.