Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Touch ID causing app to become non-responsive

Tags:

ios

ios8

touch-id

I Added ios-8's new touchID API to my app. It usually works as expected, BUT when entering app while my finger is already on home-button - API's success callback is called but pop-up still appears on screen. after pressing CANCEL UI becomes non-responsive.

like image 815
HeTzi Avatar asked Oct 20 '14 10:10

HeTzi


People also ask

How do I bypass Touch ID to install apps?

Answer: A: Answer: A: Hi, Go to settings—— Touch Id & Passcode ——Enter your passcode—- then disable the touch id for Itunes & App store.

Why does Iphone ask for passcode instead of fingerprint?

You might need to enter your passcode or Apple ID instead of using Touch ID in these situations: You just restarted your device. Your fingerprint isn't recognized five times in a row. You haven't unlocked your device in more than 48 hours.

How do I enable Touch ID on my Iphone?

Go to Settings > Touch ID & Passcode. Tap Add a Fingerprint. Follow the onscreen instructions.


1 Answers

This accepted answer does not address the underlying cause of the problem: invoking evaluatePolicy() twice, the second time while the first invocation is in progress. So the current solution only works sometimes by luck, as everything is timing dependent.

The brute-force, straightforward way to work around the problem is a simple boolean flag to prevent subsequent calls from happening until the first completes.

AppDelegate *delegate = [[UIApplication sharedApplication] delegate];
if ( NSClassFromString(@"LAContext") && ! delegate.touchIDInProgress ) {
    delegate.touchIDInProgress = YES;
    LAContext *localAuthenticationContext = [[LAContext alloc] init];
    __autoreleasing NSError *authenticationError;
    if ([localAuthenticationContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authenticationError]) {
        [localAuthenticationContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:kTouchIDReason reply:^(BOOL success, NSError *error) {
            delegate.touchIDInProgress = NO;
            if (success) {
                ...
            } else {
                ...
            }
        }];
    }
like image 179
user3273337 Avatar answered Oct 15 '22 06:10

user3273337