繁体   English   中英

local_auth iOS(扑)

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM