//1、判断系统版本是不是大于等于8.0如果大于等于的话就表示可以使用指纹识别
if([UIDevice currentDevice].systemVersion.floatValue>=8.0)
{
//判断是否可以使用指纹识别的功能,是在5S之后才可以进行使用的
//创建LA对象的上下文
LAContext * context = [[LAContext alloc]init];
//判断设备是否支持指纹识别
//Evaluate 表示评估的意思
//Policy表示的是策略
//用来检查当前设备是否可用touchID
if([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:nil])
{
//LAPolicyDeviceOwnerAuthentication如果我们三次指纹输入的都错了,就会弹出密码框,如果不进行密码输入。再次进来还可以有两次机会验证指纹如果都
错误还会继续弹出系统密码框让你输入 如果你没输入touch ID就会被锁定,而LAPolicyDeviceOwnerAuthenticationWithBiometrics不会弹出输入系统
的密码框,输入三次错误之后,默认不会做任何处理,我们还可以重新再点击指纹识别进行输入,但是如果还是输入错误两次之后touch id就会被锁定
//表示可以使用指纹识别技术
[context evaluatePolicy:LAPolicyDeviceOwnerAuthentication localizedReason:@"请验证指纹进行支付" reply:^
(BOOL success, NSError * _Nullable error) {
//里面是在子线程中执行的,所以要更新UI的话,肯定是需要回到主线程去执行的
//判断是否成功
if(success)
{
NSLog(@"%@",[NSThread currentThread]);
NSLog(@"验证成功");
}
else
{
NSLog(@"验证失败");
}
NSLog(@"%@",[NSThread currentThread]);
NSLog(@"%@",error);
if(error)
{
if(error.code==-2)
{
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertController * vc = [UIAlertController alertControllerWithTitle:@"指纹验证取消" message:@""
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction * action = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"---------");
}];
UIAlertAction * action1 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel
handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"hhhhhh");
}];
[vc addAction:action];
[vc addAction:action1];
[self presentViewController:vc animated:YES completion:nil];
});
}
else if(error.code==-1)
{
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertController * vc = [UIAlertController alertControllerWithTitle:@"指纹已经输错3次" message:
@"你还有两次机会" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction * action = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"---------");
}];
[vc addAction:action];
[self presentViewController:vc animated:YES completion:nil];
});
}
}
}];
}
}
else
{
NSLog(@"对不起,系统版本过低");
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有