【问题标题】:IOS8 get fingerprint dataIOS8获取指纹数据
【发布时间】:2015-04-07 13:22:20
【问题描述】:

在IOS8中我可以获取指纹数据并将其保存或在其他地方使用吗,

这个验证码

- (void)authenicateButtonTapped:(id)sender {
 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];

  }
}

但我不会验证用户身份,我不会获取指纹数据并将此数据发送到服务器端,然后服务器端将检查该指纹数据。

【问题讨论】:

    标签: ios objective-c swift fingerprint


    【解决方案1】:

    不,您不能读取或保存指纹数据。甚至 Apple 也不会收集这些数据。您只能使用 Touch ID 传感器使用用户已保存在系统偏好设置中的指纹解锁您的应用程序。

    【讨论】:

      【解决方案2】:

      您可以像这样进行身份验证:

       func authenticateUser() {
          let context = LAContext()
          var error: NSError?
      
          if context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) {
              let reason = "Identify yourself!"
      
              context.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: reason) {
                  [unowned self] success, authenticationError in
      
                  DispatchQueue.main.async {
                      if success {
                          let ac = UIAlertController(title: "Login with TouchID", message: "Sucessfully Login", preferredStyle: .alert)
                          ac.addAction(UIAlertAction(title: "OK", style: .default))
                          self.present(ac, animated: true)
                      } else {
                          let ac = UIAlertController(title: "Authentication failed", message: "Sorry!", preferredStyle: .alert)
                          ac.addAction(UIAlertAction(title: "OK", style: .default))
                          self.present(ac, animated: true)
                      }
                  }
              }
          } else {
              let ac = UIAlertController(title: "Touch ID not available", message: "Your device is not configured for Touch ID.", preferredStyle: .alert)
              ac.addAction(UIAlertAction(title: "OK", style: .default))
              present(ac, animated: true)
          }
      }
      

      【讨论】:

        猜你喜欢
        • 2015-03-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-04-19
        • 1970-01-01
        • 1970-01-01
        • 2016-07-23
        • 1970-01-01
        相关资源
        最近更新 更多