美文网首页
iOS指纹识别Object-C语言

iOS指纹识别Object-C语言

作者: 嘿嘿和露红叶 | 来源:发表于2018-06-10 13:41 被阅读39次

    首先引入类名:

    #import <LocalAuthentication/LocalAuthentication.h>

    其次:

    LAContext * authenticationContext = [[LAContextalloc] init];

    NSError* error = [[NSErroralloc]init];

        BOOL isTouchIdAvailable  = [authenticationContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error];

    if(isTouchIdAvailable ) {

    NSLog(@"认证策略成功");

    //可以进行指纹识别认证,在Home键录入指纹比对

            [authenticationContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometricslocalizedReason:@"需要验证您的指纹来确认您的身份信息" reply:^(BOOL success, NSError *error) {

    if(success) {

                    NSLog(@"恭喜,您通过了Touch ID指纹验证!");

    }else{

                    NSLog(@"抱歉,您未通过了Touch ID指纹验证!");

                }

            }];

    }else{

            NSLog(@"认证策略失败,error ===  %@",error);

        }

    相关文章

      网友评论

          本文标题:iOS指纹识别Object-C语言

          本文链接:https://www.haomeiwen.com/subject/gbdnxftx.html