iOS添加指纹识别

iOS 8 SDK向开发者公开了Touch ID指纹识别功能,允许App对用户身份进行本地验证。

只需要2步即可使用指纹验证身份:

1. 检查Touch ID是否可用。

2. 获得指纹验证结果。

 

 1     LAContext *myContext = [[LAContext alloc] init];
 2     if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:nil]) {
 3         [myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:@"请验证指纹" reply:^(BOOL success, NSError * _Nullable error) {
 4             if (success) {
 5                 NSLog(@"验证通过!");
 6             }else{
 7                 NSLog(@"验证失败!");
 8             }
 9         }];
10     }else{
11         NSLog(@"无法使用指纹验证!");
12     }

 

posted @ 2015-11-26 13:03  杭仔  阅读(141)  评论(0编辑  收藏  举报