由于 Apple 在 iOS 7 中发布了具有指纹扫描功能的 Xcode 5,我们可以在我们的应用程序中实现它吗?如果是,我们使用哪个 SDK 来实现。
请提供示例代码或指定我们使用哪个 SDK。
由于 Apple 在 iOS 7 中发布了具有指纹扫描功能的 Xcode 5,我们可以在我们的应用程序中实现它吗?如果是,我们使用哪个 SDK 来实现。
请提供示例代码或指定我们使用哪个 SDK。
不,指纹扫描仪对开发人员不可用,它在当前的 SDK 中可用。
使用即将推出的 iOS 8 SDK,您将能够通过官方 SDK 使用指纹扫描仪。
您可以在 iOS 中的新增功能:iOS8文档中了解有关 TouchID 的更多信息。
它可以通过使用可用于评估安全策略的LAContext(本地身份验证框架)来实现。它使用 Touch ID 传感器检查进行身份验证的人是否是设备所有者。将来可能会有其他安全策略。
这是相同的代码片段:
-(void)handlerForFingerTouch{
   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];
   }
}