标签:
首先导入LocalAuthentication框架
然后导入头文件
#import <LocalAuthentication/LAPublicDefines.h>
- (void)beginAuthentication{ LAContext *context = [[LAContext alloc] init]; NSError *eror = nil; NSString *reson = @"指纹识别"; if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&eror]) {//支持指纹识别 [context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:reson reply:^(BOOL success, NSError * _Nullable error) { if (success) {//指纹验证成功 NSLog(@"识别成功"); }else{ //具体erro.code的错误描述在LAError.h的头文件里 switch (error.code ) { case LAErrorUserFallback://用户选择输入密码 NSLog(@"输入密码"); break; case LAErrorTouchIDLockout://用户多次验证失败 NSLog(@"多次错误"); default: NSLog(@"errorcode == %@",error ); break; } } }]; }else{//不支持指纹识别 NSLog(@"%@",eror); } }
标签:
原文地址:http://www.cnblogs.com/cnman/p/5224149.html