gpt4 book ai didi

ios - 触控 ID : How to get touch id authentication attempts?

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:26:18 27 4
gpt4 key购买 nike

我需要实现触摸 ID,并且必须向用户显示剩余身份验证尝试的警报。下面的代码我正在使用。

在一次错误的身份验证尝试后不会调用回复 block 。它在 3 之后被调用继续错误的身份验证尝试。有没有什么方法可以统计错误的身份验证尝试……?

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];
});
}

最佳答案

我仔细阅读了文档,不可能在每次失败的尝试中都显示警报。只需引用文档 LocalAuthentication in iOS .

您可以在不同的错误情况下显示警报。第 3 次尝试失败后 LAError.authenticationFailed 将被调用,第 5 次尝试失败后 LAError.touchIDLockout 将被调用。您可以在此处显示警报。有关更多信息,请参阅 Apple LAError documentation.

关于ios - 触控 ID : How to get touch id authentication attempts?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43223385/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com