关于iOS 3D touch 指纹验证的随笔

file:///Users/OWen/Desktop/3DTouch.png

随着iOS系统不断的更新迭代,苹果总会推出一些新的功能,今天就研究了一下iOS8之后推出的指纹验证的功能,然后写了一个小demo,与君分享。。

上demo:   1:首先导入一个系统的库文件      #import <LocalAuthentication/LocalAuthentication.h>

                 2:

    LAContext *mycontent = [[LAContext alloc] init];

    

    NSString *myLocalizedReasonString = @"小伙子,请输入你的指纹";

    NSError *authError = nil;

    if ([mycontent canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError]) {

        

        [mycontent evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics

         

                  localizedReason:myLocalizedReasonString

         

                            reply:^(BOOL success, NSError *error) {

                                

                                if (success) {

                                    

                                    // User authenticated successfully, take appropriate action

                                    

                                } else {

                                    

                                    NSLog(@"-----%@",error);

                                    

                                    // User did not authenticate successfully, look at error and take appropriate action

                                }

                            }];

        

    } else {

        // Could not evaluate policy; look at authError and present an appropriate message to user

    }

 注意,测试神马的还得在真机上调试。

原文地址:https://www.cnblogs.com/110-913-1025/p/5566353.html