指纹识别

pragma mark - 指纹识别

  // 1.创建上下文
  LAContext *context = [[LAContext alloc] init];
  // 2.判断指纹识别是否可用
  // LAPolicyDeviceOwnerAuthentication:在iOS9类型  可以输入密码
  // LAPolicyDeviceOwnerAuthenticationWithBiometrics  iOS8使用 不可以输入密码
    if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticati on error:nil]) {
    // 3.开启指纹识别
    // localizedReason:使用原因
        [context evaluatePolicy:LAPolicyDeviceOwnerAuthentication localizedReason:@"通过Home键验证已经有手机指纹" reply:^(BOOL success, NSError * _Nullable error) {
            if (success) {
                NSLog(@"验证成功");
                // 跳转界面
            }
            if (error) {
                // -1表示验证失败
                // -8表示验证失败次数过多
                // -3表示在iOS8类型中点击了输入密码
                NSLog(@"%zd",error.code);
            }
        }];
    }

你可能感兴趣的:(指纹识别)