Ios TouchID:如何获取TouchID身份验证尝试?
我需要实现触摸ID,并且必须向用户显示关于剩余身份验证尝试的警报。下面是我使用的代码 在一次错误的身份验证尝试后,未调用应答块。它在3之后被调用,继续错误的身份验证尝试。是否有任何方法可以获得错误身份验证尝试的计数Ios TouchID:如何获取TouchID身份验证尝试?,ios,objective-c,Ios,Objective C,我需要实现触摸ID,并且必须向用户显示关于剩余身份验证尝试的警报。下面是我使用的代码 在一次错误的身份验证尝试后,未调用应答块。它在3之后被调用,继续错误的身份验证尝试。是否有任何方法可以获得错误身份验证尝试的计数 LAContext *myContext = [[LAContext alloc] init]; NSError *authError = nil; NSString *myLocalizedReasonString = @"Touch ID Test to show Touch
LAContext *myContext = [[LAContext alloc] init];
NSError *authError = nil;
NSString *myLocalizedReasonString = @"Touch ID Test to show Touch ID working in a custom app";
if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError]) {
[myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
localizedReason:myLocalizedReasonString
reply:^(BOOL success, NSError *error) {
if (success) {
dispatch_async(dispatch_get_main_queue(), ^{
[self performSegueWithIdentifier:@"Success" sender:nil];
});
} else {
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error"
message:error.description
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil, nil];
[alertView show];
NSLog(@"Switch to fall back authentication - ie, display a keypad or password entry box");
});
}
}];
} else {
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error"
message:authError.description
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil, nil];
[alertView show];
});
}
我浏览了文档,不可能在每次失败的尝试中显示警报。只需参考文档即可 .
您可以在不同的错误情况下显示警报。第三次失败尝试后LAError。将调用authenticationFailed,第五次失败尝试后LAError。将调用touchIDLockout。您可以在此处显示警报。有关更多信息,请参阅