Nó có thể đạt được bằng cách sử dụng LAContext (Local khuôn khổ xác thực) có thể được sử dụng để đánh giá một kiểm tra an ninh policy.It, sử dụng cảm biến ID Touch, rằng người chứng thực là chủ sở hữu thiết bị. Trong tương lai có thể có các chính sách bảo mật khác.
Dưới đây là đoạn mã cho cùng:
-(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];
}
}
@rckoenes là quyền 'táo dev diễn đàn trung tâm discussion' về đọc (https [là cảm biến vân tay có sẵn cho các ứng dụng khác?]: // devforums.apple.com/message/884859#884859) –