触摸ID导致应用无响应 [英] Touch ID causing app to become non-responsive

查看:121
本文介绍了触摸ID导致应用无响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用中添加了ios-8的新touchID API。
它通常按预期工作,但是当我的手指已经在主页按钮上时输入应用程序 - API的成功回调被调用但弹出窗口仍然出现在屏幕上。按下CANCEL后UI变得无响应。

I Added ios-8's new touchID API to my app. It usually works as expected, BUT when entering app while my finger is already on home-button - API's success callback is called but pop-up still appears on screen. after pressing CANCEL UI becomes non-responsive.

推荐答案

我也遇到了同样的问题,解决方法是调用Touch ID API使用高优先级队列,以及延迟:

I also encountered the same issue, and the solution was to invoke the call to the Touch ID API using a high priority queue, as well as a delay:

// Touch ID must be called with a high priority queue, otherwise it might fail.
// Also, a dispatch_after is required, otherwise we might receive "Pending UI mechanism already set."
dispatch_queue_t highPriorityQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.75 * NSEC_PER_SEC), highPriorityQueue, ^{
  LAContext *context = [[LAContext alloc] init];
  NSError *error = nil;

  // Check if device supports TouchID
  if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) {
      // TouchID supported, show it to user
      [context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
              localizedReason:@"Unlock Using Touch ID"
                        reply:^(BOOL success, NSError *error) {
                            if (success) {
                                // This action has to be on main thread and must be synchronous
                                dispatch_async(dispatch_get_main_queue(), ^{
                                    ...
                                });
                            }
                            else if (error) {
                                ...
                            }
                        }];
  }
});

在测试我们的应用程序时,我们发现延迟750毫秒是最佳的,但您的里程可能会有所不同。

When testing our app, we found a delay of 750ms to be optimal, but your mileage may vary.

更新(2015年10月3日):多个iOS开发人员,例如1Password,报告 iOS 8.2已经解决了这个问题。

Update (03/10/2015): Several iOS developers, like 1Password for example, are reporting that iOS 8.2 have finally fixed this issue.

这篇关于触摸ID导致应用无响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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