Flutter, local_auth: Face ID authentication does not work (even though it is available)
Asked Answered
C

0

7

I need to implement Face ID (biometrics) authentication inside the flutter application. I'm using flutter package "local_auth" v1.1.6 (https://pub.dev/packages/local_auth). However, the face authentication option is not available in the application when run on the desired device.

I am using following function, which is run on the button press:

Future<bool> authenticate() async {
  try {
    final canCheckBiometrics = await _auth.canCheckBiometrics;
    print('canCheckBiometrics: ');
    print(canCheckBiometrics);

    final availableBiometrics = await _auth.getAvailableBiometrics();
    print('getAvailableBiometrics: ');
    print(availableBiometrics);

    return await _auth.authenticate(
      localizedReason: 'Authenticate',
      biometricOnly: true,
    );
  } on PlatformException catch (e) {
    print(e);
    rethrow;
  }

}

However, the face authentication is never shown as an available option to authenticate, even though it is listed as an "available biometric":

I/flutter ( 4816): canCheckBiometrics:
I/flutter ( 4816): true
I/flutter ( 4816): getAvailableBiometrics:
I/flutter ( 4816): [BiometricType.fingerprint, BiometricType.face]

If both the fingerprint and the face are set on the device, the fingerprint is shown as the only available authentication option. If only face is set, the "NotEnrolled" exception is thrown by local_auth library (same if none of the methods are set):

I/flutter ( 4816): canCheckBiometrics:
I/flutter ( 4816): true
I/flutter ( 4816): getAvailableBiometrics:
I/flutter ( 4816): [BiometricType.fingerprint, BiometricType.face]
I/flutter ( 4816): PlatformException(NotEnrolled, No biometrics enrolled on this device., null, null)

For running the app I'm using ULEFONE ARMOR X7 phone with Android 10 - it has both fingerprint and Face ID authentications available and both can be used for unlocking the device screen - even if only the face is set it can be used for unlocking the screen, however it is not available inside the application.

Is there any way I can enable the Face ID authentication on this phone? It's essential for me to get this to work specifically on this device.

Critter answered 19/6, 2021 at 14:2 Comment(1)
Hi Jan, did you find a solution to this error?Stevie

© 2022 - 2024 — McMap. All rights reserved.