0

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;
    }
  }
JRV
  • 1
  • 1

1 Answers1

0

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

}

  • I got the same results – JRV Jan 23 '23 at 08:09
  • have u add this `NSFaceIDUsageDescription Why is my app authenticating using face id?` to your info.plist file – surayutttttttt Jan 23 '23 at 09:37
  • Yes I already had this. – JRV Jan 23 '23 at 10:13
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 24 '23 at 08:13