Reputation: 1
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;
}
}
Upvotes: 0
Views: 861
Reputation: 13
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.
}
}
}
Upvotes: 0