- (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. js 实现文字列表滚动效果

    今天要实现抽奖名单在首页滚动展示的效果,就用js写了一个,代码如下: html代码: <style type="text/css"> *{margin:;padding ...

  2. html 表单 dom 注意跟表单的name值一致

    html 表单 dom 注意跟表单的name值一致 <script type="text/javascript"> function checkForm() { var ...

  3. List Copy

    //要复制的实例必须可序列化,包括实例引用的其它实例都必须在类定义时加[Serializable]特性. public static T Copy<T>(T RealObject) { u ...

  4. [整理]android中几种常见的尺寸

    获取屏幕宽高尺寸的三种代码形式 在Android上,目前我知道的获取屏幕尺寸的方法有三种不同的代码形式 方法1.在Activity中最常见的调用方式 WindowManager windowManag ...

  5. radioButton

    布局: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tool ...

  6. 第五根k线

    无论是下落还是上涨的一波,到第五根k线就要注意了.要么加速,不然就要翻转了

  7. mvc-5视图和模版

    动态渲染视图 当待渲染的视图内容不多的时候,可以将视图元素放在控制器或者状态里 var views = document.getElementById("views"); view ...

  8. 模拟 POJ 1068 Parencodings

    题目地址:http://poj.org/problem?id=1068 /* 题意:给出每个右括号前的左括号总数(P序列),输出每对括号里的(包括自身)右括号总数(W序列) 模拟题:无算法,s数组把左 ...

  9. office2010永久的密钥

      1.Office Professional Plus 2010: 6QFDX-PYH2G-PPYFD-C7RJM-BBKQ8 BDD3G-XM7FB-BD2HM-YK63V-VQFDK   2.O ...

  10. Oracle 使用小计

    1.Sequence 1.1 什么是Sequence? Sequence是oracle提供的一个对象,用于产生自增的主键.这与sql server的identity是类似的. 从数学的角度来说,其为一 ...