- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event

{
//1. 判断系统版本
if ([UIDevice currentDevice].systemVersion.floatValue >= 8.0) {
//可以使用指纹识别 --> 5S 以后的机型
LAContext *context = [[LAContext alloc] init];
if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:nil]) { // 可以使用
//3. 开始启用指纹识别
//localizedReason : 显示在界面上的原因, 一般用于提示用户, 为什么要使用此功能
[context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:@"请验证指纹, 以打开高级隐藏功能" reply:^(BOOL success, NSError * _Nullable error) { //判断是否成功
if (success) {
//4. 指纹识别在更新 UI 时, 一定要注意, 在主线程更新
dispatch_sync(dispatch_get_main_queue(), ^{
[self createUIAlertController:@"验证成功"];
}); } else {
dispatch_sync(dispatch_get_main_queue(), ^{
[self createUIAlertController:@"验证失败"];
});
}
// 判断错误 如果需要区分不同的错误来提示用于, 必须判断 error
if (error) { NSLog(@"error Code: %ld",error.code); NSLog(@"error : %@",error.userInfo);
}
}];
} else { NSLog(@"对不起, 5S 以上机型才能使用此功能");
} } else { NSLog(@"对不起, 系统版本过低"); } }
-(void)createUIAlertController:(NSString*)title
{
UIAlertController * alert =[UIAlertController alertControllerWithTitle:@"提示" message:title preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction * action =[UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { }];
UIAlertAction * action1 =[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
}];
[alert addAction:action1];
[alert addAction:action];
[self presentViewController:alert animated:YES completion:nil];
}

ios-指纹识别的更多相关文章

  1. iOS指纹识别Touch ID的安全性探讨

    苹果公司在 iPhone 5s 的发布会上公布了全新的指纹识别安全技术,也就是 Touch ID,开创了生物安全识别技术在便携设备上使用的新篇章.此后,苹果还将此技术带到了 iPad 上.此前没有任何 ...

  2. IOS指纹识别调用

    最近正在开发的一个app需要加入指纹识别的功能,先搜索一下找到官方文档,简单易懂: https://developer.apple.com/library/ios/documentation/Loca ...

  3. iOS指纹识别

    #import "ViewController.h" #import <LocalAuthentication/LocalAuthentication.h> @inte ...

  4. IOS 指纹识别的简单使用

    首先导入LocalAuthentication框架 然后导入头文件 #import <LocalAuthentication/LAPublicDefines.h> - (void)begi ...

  5. iOS指纹识别代码

    1:添加LocalAuthentication.framework框架 2:实现过程 #import "ViewController.h" #import <LocalAut ...

  6. ios 指纹识别解锁

    :添加LocalAuthentication.framework框架 :实现过程 #import "ViewController.h" #import <LocalAuthe ...

  7. iOS - TouchID 指纹识别

    前言 NS_CLASS_AVAILABLE(10_10, 8_0) @interface LAContext : NSObject 指纹识别功能是 iPhone 5s 推出的,SDK 是 iOS 8. ...

  8. ios开发-指纹识别

    最近我们使用支付宝怎么软件的时候,发现可以使用指纹了,看起来是否的高大上.当时苹果推出了相关接口,让程序写起来很简单哈. 在iPhone5s的时候,苹果推出了指纹解锁.但是在ios8.0的时候苹果才推 ...

  9. 指纹识别人脸识别 iOS

    //1.判断iOS8及以后的版本 if([UIDevice currentDevice].systemVersion.doubleValue >= 8.0){ //从iPhone5S开始,出现指 ...

  10. iOS 钥匙串 指纹识别 get和Post请求的区别

    01-钥匙串 1. 通过系统提供的钥匙串功能可以在本地保存密码,系统使用AES的方式对密码加密 a. 查看Safari中保存的密码 2. 使用第三方框架SSKeychain把密码保存到钥匙串和获取钥匙 ...

随机推荐

  1. 归并排序(merge sort)

    M erge sort is based on the divide-and-conquer paradigm. Its worst-case running time has a lower ord ...

  2. C++ friend

    如果类A希望类B可以访问它的私有成员, 可以把类B设置为友元类. // 类A,希望把私有成员公开给类B class A {     friend class B;// 把B设置为友元类 public: ...

  3. Entity Framework 使用

    1.EF中Include方法的使用使用Include方法,告诉EF连接查询哪个外键属性,生成Inner join连接 //必须引用using System.Data.Entity;才能用Include ...

  4. 【现代程序设计】homework-10

    作业地址:http://www.cnblogs.com/xinz/p/3441537.html 进行中...

  5. ScrollView与ListView的冲突

    众所周知ListView与ScrollView都具有滚动能力,对于这样的View控件,当ScrollView与ListView相互嵌套会成为一种问题: 问题一:ScrollView与ListView嵌 ...

  6. 64位环境中使用SQL查询excel的方式解决

    --64位环境中使用SQL查询excel的方式 环境: OS:Windows Server 2008 R2 Enterprise MSSQL:Microsoft SQL Server 2008 R2 ...

  7. Knowledgeroot安装与使用入门

    采用 PHP 开发的知识库系统,基于树状结构对内容进行组织.使用 FCKEditor 进行内容编辑. 效果http://demo.knowledgeroot.org/index.php?id=2230 ...

  8. 字符串截取函数substr和substring的不同及其相关说明

    1.substr 方法 功能:用于返回一个从指定位置开始的指定长度的子字符串,从“母字符串”的“指定位置”开始提取“指定长度”的“子字符串”. 语法:stringObject.substr(start ...

  9. 基于Extjs的web表单设计器 第五节——数据库设计

    这里列出表单设计器系列的内容,6.7.8节的内容应该在春节后才有时间出了.因为这周末就请假回老家了,准备我的结婚大事.在此提前祝大家春节快乐! 基于Extjs的web表单设计器 基于Extjs的web ...

  10. BZOJ3073 : [Pa2011]Journeys

    用线段树套链表维护所有边,用set维护未访问过的点 然后BFS,每次在线段树上找边,然后在set中查询点 一条边使用之后就没有用了,所以在链表中将它删去 时间复杂度$O((n+m)\log n+m\l ...