我想在应用程序中实现触摸ID功能,为此我编写了代码:
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];
}
我没有支持触摸ID功能的设备,因此在哪里可以对其进行测试以查看其功能是否正常。
任何帮助,将不胜感激。谢谢。
最佳答案
您只能在真实设备上测试TouchID。模拟器不支持此功能。
关于ios - 没有iPhone 5s设备时如何测试Touch ID功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29388962/