iOS TouchID使用

引入框架#import <LocalAuthentication/LocalAuthentication.h>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
LAContext *lol = [[LAContext alloc] init];
NSError *hi = nil;
NSString *hihihihi = @"通过验证指纹解锁";
//TODO:TOUCHID是否存在
if ([lol canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&hi]) {
//TODO:TOUCHID开始运作
[lol evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:hihihihi reply:^(BOOL succes, NSError *error) {
if (succes){
//验证通过
NSLog(@"验证通过");
}else{
//验证失败 取消
NSLog(@"验证失败");
}
}];
}else{
//没有开启TOUCHID设备自行解决
NSLog(@"没有开启TOUCHID");
}

本文总阅读量