I'm trying to get biometrics authentication to work again after updating the app I'm developing. But I'm constantly getting the same error when activating it:
PlatformException(NotAvailable, Required security features not enabled, null, null)
The current one in the store has no problems at all.
I'm using local_auth: 1.1.4
MainActivity.java has been converted to a FragmentedActivity
I'm doing a simple check to see if the biometrics are available. Which they are
bool canCheckBiometrics = await auth.canCheckBiometrics;
List<BiometricType> availableBiometrics =
await auth.getAvailableBiometrics();
print(canCheckBiometrics); //Returns true
print(availableBiometrics.toString()); //Returns [BiometricType.fingerprint]
After that I try to do the authentication
try {
authenticated = await auth.authenticate(
biometricOnly: true,
localizedReason: 'Login with biometrics',
useErrorDialogs: true,
stickyAuth: false);
} on PlatformException catch (e) {
print(e);
}
This returns:
PlatformException(NotAvailable, Required security features not enabled, null, null)
And this is what the plugin comments in the code say.
// Indicates the device does not have a Touch ID/fingerprint scanner.
const String notAvailable = 'NotAvailable';
I'm not really sure what to check anymore. Is this something new I need to be aware of?
Really hope someone can help me with this issue!
Hope to hear!
I recommend that you verify all capabilities before of try authenticate the user.
Future<bool> authenticateIsAvailable() async {
final isAvailable = await localAuth.canCheckBiometrics;
final isDeviceSupported = await localAuth.isDeviceSupported();
return isAvailable && isDeviceSupported;
}
This way, you can call localAuth.authenticate
only for phones that have credentials enrolled and probably don't have exceptions. Even though, catch the error if possible.
First of all, you need to add a biometric authentication method to your device from settings.
For example if you are using Pixel 2 API 32 as Android Emulator,
Similarly, if you are trying with a real device or another emulator, you need to enable fingerprint authentication and try again.
Go to settings -> security -> fingerprint and add fingerprint lock.
If you are using Android studio emulator then keep in mind that Android Studio emulator provides fake fingerprint scanning.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With