zoukankan      html  css  js  c++  java
  • ios-指纹识别

    - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
    
    {
        //1. 判断系统版本
        if ([UIDevice currentDevice].systemVersion.floatValue >= 8.0) {
            //可以使用指纹识别 --> 5S 以后的机型
            LAContext *context = [[LAContext alloc] init];
            if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:nil]) {
                
                // 可以使用
                //3. 开始启用指纹识别
                //localizedReason : 显示在界面上的原因, 一般用于提示用户, 为什么要使用此功能
                [context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:@"请验证指纹, 以打开高级隐藏功能" reply:^(BOOL success, NSError * _Nullable error) {
                    
                    //判断是否成功
                    if (success) {
                        //4. 指纹识别在更新 UI 时, 一定要注意, 在主线程更新
                        dispatch_sync(dispatch_get_main_queue(), ^{
                            [self createUIAlertController:@"验证成功"];
                        });
                                            
                    } else {
                        dispatch_sync(dispatch_get_main_queue(), ^{
                            [self createUIAlertController:@"验证失败"];
                        });
                    }
                    // 判断错误 如果需要区分不同的错误来提示用于, 必须判断 error
                    if (error) {
                        
                        NSLog(@"error Code: %ld",error.code);
                        
                        NSLog(@"error : %@",error.userInfo);
                    }
                }];
            } else {
                
                NSLog(@"对不起, 5S 以上机型才能使用此功能");
            }
            
        } else {
            
            NSLog(@"对不起, 系统版本过低");
            
        }
        
    }
    -(void)createUIAlertController:(NSString*)title
    {
        UIAlertController * alert =[UIAlertController alertControllerWithTitle:@"提示" message:title preferredStyle:UIAlertControllerStyleAlert];
        UIAlertAction * action =[UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            
        }];
        UIAlertAction * action1 =[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        }];
        [alert addAction:action1];
        [alert addAction:action];
        [self presentViewController:alert animated:YES completion:nil];
    }

  • 相关阅读:
    MongoDB新存储引擎WiredTiger实现(事务篇)
    mongodb存储引擎WiredTiger
    WiredTiger 4.1.0 发布,MongoDB 存储引擎
    MongoDB存储引擎、索引 原
    MongoDB Wiredtiger存储引擎实现原理
    MongoDB 副本集
    MongoDB 聚合
    MongoDB 索引
    mongodb 开发规范
    MongoDB 基本操作 数据库、集合
  • 原文地址:https://www.cnblogs.com/sayimba/p/5698000.html
Copyright © 2011-2022 走看看