gpt4 book ai didi

iOS 8 Touch ID 错误 "User interaction is required."

转载 作者:技术小花猫 更新时间:2023-10-29 11:03:03 25 4
gpt4 key购买 nike

我一直致力于将 Touch ID 支持集成到我正在开发的应用程序中。然而,它的行为非常不一致。我看到的一个常见问题是在新的应用程序启动时它按预期工作,但是在后台应用程序并将其带到前台时我从

返回错误
evaluatePolicy:localizedReason:reply:

它甚至没有多大意义(我从来没有看到 touchid 警报)

Error Domain=com.apple.LocalAuthentication Code=-1004 "User interaction is required." UserInfo=0x171470a00 {NSLocalizedDescription=User interaction is required.}

我已经尝试在应用程序已经运行时显示 touchid 警报,当它刚刚出现时,似乎并不重要。每次应用程序首次启动后,它都会中断。

还有其他人遇到这个问题吗?

作为引用,这是我正在使用的代码:

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

最佳答案

通常在进入后台之前推送 PIN View Controller :

- (void)applicationDidEnterBackground:(UIApplication *)application

因此,在翻阅应用预览图像(双击主页按钮)时,不会显示应用的内部信息。我猜你正在做类似的事情。

问题是 LocalAuthentication 的新 API 要求调用 viewController 可见。这就是为什么你不应该在退出后台之前调用你的“showTouchID”功能。而是在进入前台时调用“showTouchID”函数:

- (void)applicationWillEnterForeground:(UIApplication *)application

它应该有效。不要忘记在应用程序首次启动时调用它(在这种情况下 ..willEnterForeground 将不会被调用)。

关于iOS 8 Touch ID 错误 "User interaction is required.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25919482/

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