Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter - Local_auth (Required security features not enabled)

Tags:

flutter

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!

like image 871
Kevin Walter Avatar asked Apr 16 '21 08:04

Kevin Walter


3 Answers

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.

like image 161
isacjunior Avatar answered Oct 23 '22 15:10

isacjunior


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,

  • Go to Settings inside android emulator.
  • Go into Security
  • Under the Device Security section, select Pixel Imprint
  • Android will ask you to put your finger on the sensor, in this part you should click the Touch Sensor button from the Extended Emulator Settings of Android Studio.

Extended Emulator Settings Pixel 2 API 32

  • After turning on fingerprint verification in this way, when you return to the application and try again, you will see that the error is gone.

Similarly, if you are trying with a real device or another emulator, you need to enable fingerprint authentication and try again.

like image 4
okan Avatar answered Oct 23 '22 15:10

okan


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.enter image description here

like image 1
Anas Nadeem Avatar answered Oct 23 '22 13:10

Anas Nadeem