[英]local_auth iOS (Flutter)
Flutter 當為 iOS 禁用生物識別和密碼時,local_auth 沒有返回平台異常。
我有一個功能,如果生物識別和密碼被禁用,我將使用另一個 function 進行身份驗證,但它只適用於 Android 而不適用於 iOS。
Future<bool> authentication() async {
try {
return await _localAuthentication.authenticate(
localizedReason: Strings.localAuthReason,
useErrorDialogs: true,
stickyAuth: true,
);
} on PlatformException {
return false;
}
}
導入下面的代碼 import 'package:local_auth/error_codes.dart' as local_auth_error;
試試這個
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.