iOS 关于指纹识别的一点笔记

#pragma mark 使用指纹解锁
-(void)userTouchId
{
    
    NSLog(@"指纹解锁预备");
    LAContext  *locontext= [[LAContext alloc] init];
    
    locontext.localizedFallbackTitle= @"使用手势解锁密码";
    
    NSError *err;
    //3.判断设备是否支持指纹识别
    
    if ([locontext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&err]) {
        //是否支持
        NSLog(@"指纹解锁判断");
        [locontext  evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:@"通过验证指纹解锁泰和网" reply:^(BOOL success, NSError * _Nullable error) {
            NSLog(@"开始指纹解锁");
            if (success) {
                NSLog(@"解锁成功");
                // 解锁成功 进入程序
                [self.tabBarController dismissViewControllerAnimated:YES completion:nil];
                [self.tabBarController showLaunchView];
            }else{
                NSLog(@"认证失败");
                /*switch (error.code) {
                    case LAErrorUserCancel:
                    {
                        NSLog(@"用户取消");
                         break;
                    }
                    case LAErrorAuthenticationFailed:
                    {
                        NSLog(@"认证失败");
                        break;
                    }
                    case LAErrorPasscodeNotSet:
                    {
                        NSLog(@"未设置密码");
                        break;
                    }
                    case LAErrorSystemCancel:
                    {
                        NSLog(@"系统取消");
                        break;
                    }
                    case LAErrorUserFallback:
                    {
                        NSLog(@"点击输入密码");
                        break;
                    }
                    default:
                        break;
                }
            }
            
        }];
    }else{
        NSLog(@"设备不支持指纹解锁 %@", err);
    }
    
}


你可能感兴趣的:(iOS 关于指纹识别的一点笔记)