iOS - (个人隐私钱包调用系统本机TouchID指纹锁验证)
//
// ViewController.m
// TouchID指纹验证
//
// Created by apple on 16/9/18.
// Copyright © 2016年 apple. All rights reserved.
//
#import "ViewController.h"
#import "HomeViewController.h"//跳转成功后需要跳转到的视图控制器
#import <LocalAuthentication/LocalAuthentication.h>//导入TouchID需要的类库
#import <sys/utsname.h> //获取设备基本信息需要的类库
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self touchID];
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
//调用TouchID会执行此方法,有需要可以实现一些另外的功能
}
- (void)touchID {
LAContext *context = [[LAContext alloc] init];
NSError *error = nil;
// 第一步判断是否支持Touch ID 或者 本机是否已经录入指纹
if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) {
[context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:@"请验证已有指纹" reply:^(BOOL success, NSError * _Nullable error) {
if (error) {
NSLog(@"验证失败"); // 系统会自动给错误提示
}else{
dispatch_async(dispatch_get_main_queue(), ^{
// 指纹验证成功后跳转
HomeViewController *home = [[HomeViewController alloc] init];
[self presentViewController:home animated:YES completion:nil];
});
}
}];
}else {
// 判断是否真机运行
if (self.isSimulator) {
[[[UIAlertView alloc] initWithTitle:@"提示" message:@"请用真机测试~" delegate:nil cancelButtonTitle:@"好的" otherButtonTitles:nil, nil] show];
}else{
[[[UIAlertView alloc] initWithTitle:@"提示" message:@"不支持Touch ID~" delegate:nil cancelButtonTitle:@"好的" otherButtonTitles:nil, nil] show];
}
}
}
// 判断当前设备是否支持TouchID功能
- (BOOL)isSimulator{
struct utsname systemInfo;
uname(&systemInfo);
NSString *deviceMachine = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
if ([deviceMachine isEqualToString:@"i386"] || [deviceMachine isEqualToString:@"x86_64"]) {
return YES;
}
return NO;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
iOS - (个人隐私钱包调用系统本机TouchID指纹锁验证)的更多相关文章
- iOS - (调用系统本机发送短信功能)
今天处理一个订单详情的界面,在订单详情页面上有联系方式(电话号码),在电话号码的右边有两图片,一个是电话样式的,一个是短信样式的,做为一名程序员(号称攻城师)一眼看下去就应该是一个 button,而不 ...
- iOS - (调用系统本机打电话功能)
如下图所示,点击订单里的打电话 button 后,调用系统的打电话功能. 这个调用系统打电话功能有点简单,不需要遵守协议和代理什么的,直接在点击方法里写上几句代码就可以了. 下面来看看代码吧: 接下来 ...
- iOS中 读取相册,调用系统相机 技术分享
技术内容:分别读取相册以及调取相机,将图片显示到imageView上 布局: 1.创建imageView 和 button 并为button一个关联pickerImage的事件 <div sty ...
- ios openURL的使用(调用系统电话、浏览器、地图、邮件等)
Safari Any URL starting with http:// which does not point to maps.google.com or www.youtube.com is s ...
- IOS中调用系统的电话、短信、邮件、浏览功能
iOS开发系列--通讯录.蓝牙.内购.GameCenter.iCloud.Passbook系统服务开发汇总 2015-01-13 09:16 by KenshinCui, 26990 阅读, 35 评 ...
- ios调用系统相册、相机 显示中文标题、本地化多语言支持
因为调用系统相册.相机需要显示中文,所以搞了半天才知道是在Project->info->Custom ios Target Properties 添加 Localizations 并加入C ...
- iOS调用系统通讯录获取姓名电话号码(转)
原文地址:http://blog.csdn.net/idoshi201109/article/details/46007125 OS调用系统通讯录获取姓名电话号码 (iOS 8.0 Xcode6.3可 ...
- ios 调用系统应用的方法 应用间跳转的方法
声明一个私有方法: #pragma mark - 私有方法 -(void)openUrl:(NSString *)urlStr{ //注意url中包含协议名称,iOS根据协议确定调用哪个应用,例如发送 ...
- iOS (封装)一句话调用系统的alertView和alertController
前言: 本文仅作参考存留,请用新版封装:iOS 更加优雅便捷的UIAlertView/UIAlertController封装使用 UIAlertController是iOS8.0之后出来的新方法,其将 ...
随机推荐
- cURL 学习笔记与总结(5)用 cURL 访问 HTTPS 资源
<?php $curlobj = curl_init(); // 初始化 curl_setopt($curlobj, CURLOPT_URL, "https://ajax.aspnet ...
- Failed to connect to remote VM. Connection refused. Connection refused: connect.
eclipse debug启动经常出现这个错误,已经启动了debug进程,X掉重新启动即可.
- Visual Studio快捷键不能使用解决办法
环境: Visual Studio 2010,windows 7 使用Visual Studio查找变量或方法时常用到[定位到]功能 但该功能的快捷键却不能使用,解决办法如下所示: 1.工具--> ...
- HTML: a的僞類
a:link a:visited a:hover a:active css中能夠分別針對a鏈接的4中狀態進行css樣式設置,這四種狀態就是a的僞類,分別是: 普通,訪問後,鼠標放在a鏈接上,鼠標按下未 ...
- 云计算中心网络资源分配-Faircloud: sharing the network in cloud computing
网络资源同计算资源以及存储资源一样,是一种可被租户共享使用并提高利用率的资源.但是,不同租户的计算资源以及存储资源之间,有很强的隔离性,可以实现按需按比例分配的使用方式,但是网络资源却不可以. 主要原 ...
- Kafka 0.10.0
2.1 Producer API We encourage all new development to use the new Java producer. This client is produ ...
- HybridTime - Accessible Global Consistency with High Clock Uncertainty
Amazon's Dynamo [9] and Facebook's Cassandra [13], relax the consistency model,and offer only eventu ...
- 哈哈,好像swift 以后有可能用来开发安卓喔
好像swift 以后有可能用来开发安卓喔,哈哈
- MongoDB上的索引
1. 将索引建在number键上名为nameIndex并且为正序索引({number:-1}为倒序索引) 如: db.list名.ensureIndex({number:1},{name:" ...
- 用Js的eval解析JSON中的注意点
在JS中将JSON的字符串解析成JSON数据格式,一般有两种方式: 1.一种为使用eval()函数. 2. 使用Function对象来进行返回解析. 使用eval函数来解析,并且使用jquery的ea ...