Search code examples
iosiphonexcodeauthenticationtouch-id

After authentication by TouchID calling Method don't working


After make a authentication if i press cancel and set [buttonTouch setHidden:NO]; to appear, the button does not appear immediately, takes too long to appear despite the be functioning button event.

My Code:

if ([context canEvaluatePolicy: LAPolicyDeviceOwnerAuthenticationWithBiometrics error:nil]){
        NSLog(@"TouchID Available!");

        [context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:@"Authenticate for server login" reply:^(BOOL success, NSError *authenticationError){
            if (success) {
                [self dismissViewControllerAnimated:YES completion:nil];
                //[self VerifyUserInfo:YES];
                NSLog(@"Fingerprint validated.");
            }else{
                NSLog(@"Fingerprint validation failed: %@.", authenticationError.localizedDescription);
                switch (authenticationError.code) {
                    case LAErrorAuthenticationFailed:
                        [self AlertsMessage:@"Authentication is failed"];
                        NSLog(@"Authentication Failed");
                        break;

                    case LAErrorUserCancel:
                        [buttonTouch setHidden:NO];
                        NSLog(@"User pressed Cancel button");
                        break;

                    case LAErrorUserFallback:
                        [buttonTouch setHidden:NO];
                        NSLog(@"User pressed \"Enter Password\"");
                        break;

                    default:
                        [self AlertsMessage:@"Touch ID is not configured"];
                        NSLog(@"Touch ID is not configured");
                        break;
                }

                NSLog(@"Authentication Fails");
            }
        }];

Solution

  • Call

     dispatch_async(dispatch_get_main_queue(), ^{
    
                    [buttonTouch setHidden:NO];
    
                });