ios使用touchId

来源:互联网 发布:国际阿里云 编辑:程序博客网 时间:2024/05/22 13:12

#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            }


1 0
原创粉丝点击