zoukankan      html  css  js  c++  java
  • iOS8.0如何使用Touch ID来做验证

    对于Objective-C而言,只要几行代码即可搞定。

    比如:

    #import <LocalAuthentication/LocalAuthentication.h>
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.
        
        LAContext *context = [[LAContext alloc] init];
        if(![context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:nil])
            NSLog(@"Touch ID not supported!");
        
        [context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:@"找回密码" reply:^void(BOOL success, NSError *error){
            NSLog(@"Is success? %d", success);
            if(!success)
            {
                switch(error.code) {
                    case LAErrorAuthenticationFailed:
                        NSLog(@"Authentication Failed");
                        break;
                        
                    case LAErrorUserCancel:
                        NSLog(@"User Cancelled");
                        break;
                        
                    case LAErrorUserFallback:
                        NSLog(@"User Fallback");
                        break;
                        
                    case LAErrorSystemCancel:
                        NSLog(@"System Cancelled");
                        break;
                        
                    case LAErrorPasscodeNotSet:
                        NSLog(@"Passcode Not Set");
                        break;
                        
                    case LAErrorTouchIDNotAvailable:
                        NSLog(@"Touch ID Not Available");
                        break;
                        
                    default:
                        break;
                }
            }
        }];
    }
  • 相关阅读:
    利用django创建一个投票网站(二)
    利用django创建一个投票网站(一)
    django models进行数据库增删查改
    用pyspider爬淘宝MM照片
    爬虫实现模拟登陆豆瓣
    python-study-32
    python-study-31
    python-study-30
    python-周考2
    python-周考3
  • 原文地址:https://www.cnblogs.com/zenny-chen/p/4387666.html
Copyright © 2011-2022 走看看