3

It seems like Face Id is ignoring localizedFallbackTitle and localizedReason. However localizedCancelTitle is working fine. Does anyone know how to get it work?

My code:

LAContext *context = [[LAContext alloc] init];
if ([context respondsToSelector:@selector(setLocalizedCancelTitle:)]) {
    context.localizedCancelTitle = [Language get:CANCEL alter:nil];
}

if ([context respondsToSelector:@selector(setLocalizedFallbackTitle:)])
{
    context.localizedFallbackTitle = [Language get:TRY_AGAIN alter:nil];
}

NSError *error = nil;
if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthentication error:&error]) {
   [context evaluatePolicy:LAPolicyDeviceOwnerAuthentication
   localizedReason:[Language get:AUTHRNTICATE_USING_YOUR_FACE alter:nil] reply:^(BOOL success, NSError *error) {
   //code
}

Screenshot:

Nonmatching face popup

I want to localize everything on this popup if possible.

Note: Attached screenshot is taken on simulator. I have also checked it on real device but the result is same. Also, for Touch id it is working properly.

piet.t
  • 11,718
  • 21
  • 43
  • 52
Sanket_B
  • 735
  • 9
  • 26

1 Answers1

0

According to this Post, there is no API for changing the Reason in between the auth process.

localizedReason

The app-provided reason for requesting authentication, which displays in > the authentication dialog presented to the user.

You can use BiometricAuthentication to show your message.

BioMetricAuthenticator.authenticateWithBioMetrics(reason: "", success: {

    // authentication successful

}, failure: { [weak self] (error) in

    // do nothing on canceled
    if error == .canceledByUser || error == .canceledBySystem {
        return
    }
    
    // device does not support biometric (face id or touch id) authentication
    else if error == .biometryNotAvailable {
        self?.showErrorAlert(message: error.message())
    }

    // show alternatives on fallback button clicked
    else if error == .fallback {

        // here we're entering username and password
        self?.txtUsername.becomeFirstResponder()
    }

    // No biometry enrolled in this device, ask user to register fingerprint or face
    else if error == .biometryNotEnrolled {
        self?.showGotoSettingsAlert(message: error.message())
    }

    // Biometry is locked out now, because there were too many failed attempts.
    // Need to enter device passcode to unlock.
    else if error == .biometryLockedout {
        // show passcode authentication
    }

    // show error on authentication failed
    else {
        self?.showErrorAlert(message: error.message())
    }
})
Community
  • 1
  • 1
Reza Dehnavi
  • 2,256
  • 3
  • 16
  • 30