ios使用touchId

#import <LocalAuthentication/LAContext.h>




    LAContext *myContext = [[LAContext alloc] init];
    
    NSError *authError = nil;
    
    NSString *myLocalizedReasonString = @"请输入指纹";
    
    
    if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError]) {//判断是否有指纹识别
        
        [myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
         
                  localizedReason:myLocalizedReasonString
         
                            reply:^(BOOL success, NSError *error) {
                                
                                if (success) {
                                    UIAlertView *al = [[UIAlertView alloc]initWithTitle:nil message:@"success" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles: nil];
                                    [al show];
                                    NSLog(@"success");
                                    // User authenticated successfully, take appropriate action
                                    
                                } else {
                                    UIAlertView *al = [[UIAlertView alloc]initWithTitle:nil message:@"失败" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles: nil];
                                    [al show];
                                    NSLog(@"faill");
                                    
                                }
                                
                            }];
        
    } else {
        
        // Could not evaluate policy; look at authError and present an appropriate message to user
        
    }


郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。