ios - 没有iPhone 5s设备时如何测试Touch ID功能

标签 ios touch-id

我想在应用程序中实现触摸ID功能,为此我编写了代码:

LAContext *context = [[LAContext alloc] init];

        NSError *error = nil;
        if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) {
            [context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
                    localizedReason:@"Are you the device owner?"
                              reply:^(BOOL success, NSError *error) {

                                  if (error) {
                                      UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"
                                                                                      message:@"There was a problem verifying your identity."
                                                                                     delegate:nil
                                                                            cancelButtonTitle:@"Ok"
                                                                            otherButtonTitles:nil];
                                      [alert show];
                                      return;
                                  }

                                  if (success) {
                                      UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Success"
                                                                                      message:@"You are the device owner!"
                                                                                     delegate:nil
                                                                            cancelButtonTitle:@"Ok"
                                                                            otherButtonTitles:nil];
                                      [alert show];

                                  } else {
                                      UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"
                                                                                      message:@"You are not the device owner."
                                                                                     delegate:nil
                                                                            cancelButtonTitle:@"Ok"
                                                                            otherButtonTitles:nil];
                                      [alert show];
                                  }

                              }];

        } else {

            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"
                                                            message:@"Your device cannot authenticate using TouchID."
                                                           delegate:nil
                                                  cancelButtonTitle:@"Ok"
                                                  otherButtonTitles:nil];
            [alert show];

        }

我没有支持触摸ID功能的设备,因此在哪里可以对其进行测试以查看其功能是否正常。

任何帮助,将不胜感激。谢谢。

最佳答案

您只能在真实设备上测试TouchID。模拟器不支持此功能。

关于ios - 没有iPhone 5s设备时如何测试Touch ID功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29388962/

相关文章:

ios - 根据属性比较并返回不同的 swift 数组对象

ios - 绑定(bind)到 MvvmCross 中的 UIBarButtonItem 事件

ios - 检查 FaceID 是否正确?

swift - 如何在收到通知且启用 Touch ID 时打开特定 ViewController

ios - 更改警报 View 可见时按主页按钮的默认行为

iphone - SBJSON 解析器内存泄漏

objective-c - 如何在 AppDelegate 中执行 Segue?

ios - 如何使用 Storyboard 中制作的 UIBarButtonItem 设置操作

ios - 防止在我的应用程序中使用未经授权人员的 TouchID 注册指纹

ios - 是否可以检测用户在进入我的应用程序之前是否输入了他们的 Touch ID