iOS 8 Touch ID错误“需要用户交互。” [英] iOS 8 Touch ID error "User interaction is required."

查看:181
本文介绍了iOS 8 Touch ID错误“需要用户交互。”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在努力将Touch ID支持集成到我正在处理的应用中。然而,它表现得非常不一致。我看到的一个常见问题是在一个新的应用程序启动它按预期工作,但然后在后台应用程序,并将其带到前台我收到一个错误从

I have been working on integrating Touch ID support into an app I am working on. It is however acting very inconsistent. One of the common issues I am seeing is on a fresh app launch it works as expected, but then on backgrounding the app, and bringing it to the foreground I am getting an error back from

evaluatePolicy:localizedReason:reply:

确实如此甚至没有多大意义(我从未看到过触摸警报)

It does not even make a lot of sense (I never see the touchid alert)

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

我尝试过提交touchid警报应用程序已经运行,当它刚刚开始时,似乎并不重要。在最初的应用程序启动后,它每次都会被破坏。

I have tried presenting the touchid alert when the app is already running, when its just foregrounded, does not seem to matter. Its broken on every time after the initial app launch.

其他人遇到这个?

供参考,这是我正在使用的代码:

For reference, here is the code I am 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];
                    });
                }
            });
        }];
    }
}


推荐答案

通常PIN视图控制器在进入后台之前被推送:

Usually PIN view controllers are pushed before entering background in:

- (void)applicationDidEnterBackground:(UIApplication *)application


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

So app's inner information won't appear when paging through app preview images (home button double tap). I guess you are doing something similar.

问题是LocalAuthentication的新API需要调用viewController才能看到。
这就是为什么你不应该在辞职到后台之前调用你的showTouchID函数。而是在输入前景时调用showTouchID函数:

The problem is that LocalAuthentication's new API requires the calling viewController to be visible. This is why you shouldn't call your "showTouchID" function before resigning to background. Instead call "showTouchID" function when entering foreground:

- (void)applicationWillEnterForeground:(UIApplication *)application


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

And it should work. Don't forget to call it also when app is first launched (in which case ..willEnterForeground will not get called).

这篇关于iOS 8 Touch ID错误“需要用户交互。”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆