我正在尝试创建一个具有 Face id 功能的应用程序。但是当我尝试处理错误代码时,我只能捕获 LAErrorUserCancel。我无法捕获其他错误代码,例如 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;
}
}
}];