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

NSError *error = nil;

if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) {
[context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
localizedReason:@”Login with Touch ID”
reply:^(BOOL success, NSError *error) {

if (error) {

UIAlertView *Alert = [[UIAlertView alloc] initWithTitle:@”Login” message:@”Login Fail” delegate:self cancelButtonTitle:@”Close” otherButtonTitles:nil, nil];
[Alert show];                                  }

if (success) {
[self dismissViewControllerAnimated:YES completion:nil];
} 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];

}

You may also like

Leave a Reply