I am working on integrating Touch ID support into the application I'm working on. However, it is very incompatible. One of the common problems that I see is launching a new application that works as expected, but then, relying on the application and bringing it to the forefront, I get an error message from
evaluatePolicy:localizedReason:reply:
It doesn't even make much sense (I never see a touch)
Error Domain=com.apple.LocalAuthentication Code=-1004 "User interaction is required." UserInfo=0x171470a00 {NSLocalizedDescription=User interaction is required.}
I tried to provide a touchid alert when the application is already running, when its just foreground does not seem to matter. It was broken every time after the first launch of the application.
Anyone else run into this?
For reference, here is the code I'm using:
if (_useTouchId && [LAContext class]) { LAContext *myContext = [[LAContext alloc] init]; NSError *authError = nil; if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError]) { _didPresentTouchId = YES; [myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:@"Use your Touch ID to open *****" reply:^(BOOL success, NSError *error) { dispatch_async(dispatch_get_main_queue(), ^ { if (success) { _isClosing = YES; [self hide]; if (_successBlock) { _successBlock(); } } else if (error && error.code != -2 && error.code != -3 && error.code != -1004) { [[[UIAlertView alloc] initWithTitle:@"Error" message:@"Authentication failed, please enter your Pin" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil] show]; } else { if (error) { DDLogError(@"TouchID error: %@", error.description); } dispatch_after(dispatch_time(DISPATCH_TIME_NOW, .6 * NSEC_PER_SEC), dispatch_get_main_queue(), ^ { [self keyboardButtonTouched]; }); } }); }]; } }
ios objective-c touch-id
Stephen bradley
source share