IOS8 получить данные отпечатков пальцев

В 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];

  }
}

но я не проверяю подлинность пользователя, я не получаю данные отпечатка пальца и не отправляю эти данные на серверную часть, тогда серверная сторона проверит эти данные отпечатка пальца.

2 ответа

Решение

Нет, вы не можете прочитать или сохранить данные отпечатков пальцев. Даже Apple не собирает эти данные. Вы можете использовать сенсорный датчик Touch ID только для того, чтобы разблокировать приложение с отпечатками пальцев, которые пользователь уже сохранил в системных настройках.

Вы можете аутентифицироваться следующим образом:

 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)
    }
}

Другие вопросы по тегам