#import <LocalAuthentication/LocalAuthentication.h>
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:@"" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
[alertController addAction:cancelAction];
LAContext *context = [[LAContext alloc] init];
NSError *error = nil;
// 检查设备是不是支持指纹识别
if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) {
// 判断输入的指纹是否正确
[context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:@"请将手指放到Home键上" reply:^(BOOL success, NSError * _Nullable error) {
if (success) alertController.title = @"识别成功";
else alertController.title = @"未能识别";
[self presentViewController:alertController animated:YES completion:nil];
}];
} else {
alertController.title = @"硬件不支持";
[self presentViewController:alertController animated:YES completion:nil];
}