指纹识别

2017-07-20  本文已影响0人  董立权
//导入本地授权
#import <LocalAuthentication/LocalAuthentication.h>
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    //1.创建上下文
    LAContext *context = [[LAContext alloc] init];
    //2.判断指纹识别是否可用
    /*
     LAPolicyDeviceOwnerAuthenticationWithBiometrics kLAPolicyDeviceOwnerAuthenticationWithBiometrics
     */
    if([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:nil]){
        [context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:@"按住Home键验证" reply:^(BOOL success, NSError * _Nullable error) {
            if(error){
                //-1表示连续错误3次
                //-8再次错误
                //-3点击输入密码
                NSLog(@"%zd",error.code);
            }
            if(success){
                NSLog(@"验证成功");
            }
        }];
    }
}
上一篇下一篇

猜你喜欢

热点阅读