简体   繁体   中英

local_auth iOS (Flutter)

Flutter local_auth didn't return platform exception when biometrics and passcode are disable for iOS.

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.

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;

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.
  }
}

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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