iPhone X Face ID判断

来源:互联网 发布:js动态创建div容器 编辑:程序博客网 时间:2024/05/16 12:05

判断方法

if (@available(iOS 8.0, *)) {

        LAContext *context = [[LAContextalloc] init];

        NSString *localizedReason = @"指纹登录";

        if (@available(iOS 11.0, *)) {

            if (context.biometryType ==LABiometryTypeTouchID) {

            }elseif (context.biometryType ==LABiometryTypeFaceID){

                localizedReason = @"Face ID登录";

            }

        } else {

            // Fallback on earlier versions

        }

        [self authenticationWithType:localizedReasonwithContent:context];

    }else {

        NSLog(@"你的设备不支持指纹识别");

    }

}


登录方法:

- (void)authenticationWithType:(NSString *)type withContent:(LAContext *)context{

    if ([contextcanEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometricserror:nil]) {

        [context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometricslocalizedReason:type reply:^(BOOL success,                 NSError *_Nullable error) {

            if (success) {

                NSLog(@"--------识别成功");

            }else{

                if (error.code != 2) {

                    

                }

            }

        }];

    }

}


阅读全文
1 0
原创粉丝点击