Robert Enriquez
Robert Enriquez

Reputation: 21

Unable to get error code for LAErrorAuthenticationFailed in IOS FaceID

Im trying to create an app with Face id feature. But when I try to handle the error codes, i can only catch the LAErrorUserCancel. I was unable to catch other error codes such as LAErrorAuthenticationFailed.

        [context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:@"asd"   reply:
         ^(BOOL success, NSError *authenticationError) {

             if (success) {
                 [[NSOperationQueue mainQueue] addOperationWithBlock:^(void){
                     [NSTimer scheduledTimerWithTimeInterval:1/40
                                                      target:self
                                                    selector:@selector(registerTouchID)
                                                    userInfo:nil
                                                     repeats:NO];
                 }];
             }
             else {
                 switch (authenticationError.code) {
                     case LAErrorAuthenticationFailed:
                         dispatch_async(dispatch_get_main_queue(), ^{
                            [self TouchFail];
                         });
                         break;

                     case LAErrorUserCancel:
                         NSLog(@"User pressed Cancel button");
                         break;

                     case LAErrorUserFallback:
                         NSLog(@"User pressed \"Enter Password\"");
                         break;

                     case LAErrorBiometryLockout:
                         dispatch_async(dispatch_get_main_queue(), ^{
                             [self LockoutAlert];
                         });
                         break;
                     default:
                         break;
                 }
             }
         }];

Upvotes: 2

Views: 303

Answers (2)

Thafer Shahin
Thafer Shahin

Reputation: 874

Currently, iOS will show "Cancel" button after failed FaceID attempts. That's why we're getting "LAErrorUserCancel".

For TouchID it returns "LAErrorAuthenticationFailed"

Upvotes: 1

You can get the error code by error. _code =-6 or -4 like that...

Just use PO statement in logs to get the error and handle accordingly.

Upvotes: -2

Related Questions