首页 > 移动平台 > 详细

iOS指纹识别代码

时间:2015-12-05 19:10:44      阅读:343      评论:0      收藏:0      [点我收藏+]
1:添加LocalAuthentication.framework框架
2:实现过程
#import "ViewController.h"
#import <LocalAuthentication/LAContext.h>
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
  
    LAContext *myContext = [[LAContext alloc]init];
    myContext.localizedFallbackTitle = @"忘记密码";
    
    NSError *error = nil;
    NSString *myLocalizedReasonString = @"请输入指纹";
    if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) {
       
        [myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
       
                  localizedReason:myLocalizedReasonString
        
                            reply:^(BOOL success, NSError *error) {
                               
                                if (success) {
                                   
                                    NSLog(@"success");
                                   
                                } else {
                                   
                                    // User did not authenticate successfully, look at error and take appropriate action
                                 NSLog(@"did not authenticate successfully");
                                  
                                }                              
                            }];
       
    } else {
        // Could not evaluate policy; look at authError and present an appropriate message to user
       NSLog(@"Could not evaluate policy");
    }  
}

iOS指纹识别代码

原文:http://www.cnblogs.com/jaredcoder/p/5021976.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!