美文网首页
指纹识别

指纹识别

作者: 董立权 | 来源:发表于2017-07-20 12:49 被阅读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(@"验证成功");
                }
            }];
        }
    }
    

    相关文章

      网友评论

          本文标题:指纹识别

          本文链接:https://www.haomeiwen.com/subject/ojvdkxtx.html