码迷,mamicode.com
首页 > 移动开发 > 详细

ios 指纹识别解锁

时间:2015-06-06 10:29:50      阅读:155      评论: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/thbbsky/p/4556103.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!