#import <LocalAuthentication/LAContext.h>
LAContext *myContext = [[LAContext alloc] init];
NSError *authError = nil;
NSString *myLocalizedReasonString = @"请输入指纹";
if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError]) {//判断是否有指纹识别
[myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
localizedReason:myLocalizedReasonString
reply:^(BOOL success, NSError *error) {
if (success) {
UIAlertView *al = [[UIAlertView alloc]initWithTitle:nil message:@"success" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles: nil];
[al show];
NSLog(@"success");
// User authenticated successfully, take appropriate action
} else {
UIAlertView *al = [[UIAlertView alloc]initWithTitle:nil message:@"失败" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles: nil];
[al show];
NSLog(@"faill");
}
}];
} else {
// Could not evaluate policy; look at authError and present an appropriate message to user
}