//

//  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指纹锁验证)的更多相关文章

  1. iOS - (调用系统本机发送短信功能)

    今天处理一个订单详情的界面,在订单详情页面上有联系方式(电话号码),在电话号码的右边有两图片,一个是电话样式的,一个是短信样式的,做为一名程序员(号称攻城师)一眼看下去就应该是一个 button,而不 ...

  2. iOS - (调用系统本机打电话功能)

    如下图所示,点击订单里的打电话 button 后,调用系统的打电话功能. 这个调用系统打电话功能有点简单,不需要遵守协议和代理什么的,直接在点击方法里写上几句代码就可以了. 下面来看看代码吧: 接下来 ...

  3. iOS中 读取相册,调用系统相机 技术分享

    技术内容:分别读取相册以及调取相机,将图片显示到imageView上 布局: 1.创建imageView 和 button 并为button一个关联pickerImage的事件 <div sty ...

  4. ios openURL的使用(调用系统电话、浏览器、地图、邮件等)

    Safari Any URL starting with http:// which does not point to maps.google.com or www.youtube.com is s ...

  5. IOS中调用系统的电话、短信、邮件、浏览功能

    iOS开发系列--通讯录.蓝牙.内购.GameCenter.iCloud.Passbook系统服务开发汇总 2015-01-13 09:16 by KenshinCui, 26990 阅读, 35 评 ...

  6. ios调用系统相册、相机 显示中文标题、本地化多语言支持

    因为调用系统相册.相机需要显示中文,所以搞了半天才知道是在Project->info->Custom ios Target Properties 添加 Localizations 并加入C ...

  7. iOS调用系统通讯录获取姓名电话号码(转)

    原文地址:http://blog.csdn.net/idoshi201109/article/details/46007125 OS调用系统通讯录获取姓名电话号码 (iOS 8.0 Xcode6.3可 ...

  8. ios 调用系统应用的方法 应用间跳转的方法

    声明一个私有方法: #pragma mark - 私有方法 -(void)openUrl:(NSString *)urlStr{ //注意url中包含协议名称,iOS根据协议确定调用哪个应用,例如发送 ...

  9. iOS (封装)一句话调用系统的alertView和alertController

    前言: 本文仅作参考存留,请用新版封装:iOS 更加优雅便捷的UIAlertView/UIAlertController封装使用 UIAlertController是iOS8.0之后出来的新方法,其将 ...

随机推荐

  1. Happy

    1.delighted 2.over the moon                   Alex is over the moon with promotion. 3.really pleased ...

  2. LR中Vugen的多进程与多线程(脚本命令行)

    Controller使用驱动程序(如mdrv.exe或r3vuser.exe)来运行Vuser.用户可以在Controller的run-time setting中选择Vuser的运行方式:多进程/多线 ...

  3. data-"mit.edu-Thinking In C++"

    Volume 2 ctrl+s http://web.mit.edu/merolish/ticpp/TicV2.html http://web.mit.edu/merolish/ticpp/TicV2 ...

  4. java,for循环中的穷举、迭代、冒泡例题

    1.100以内与7相关的数 //100以内与7相关的数: public static void main1(String[] args) { for(int i=1;i<=100;i++){ i ...

  5. IO流学习小结

    今天刚刚看完java的io流操作,把主要的脉络看了一遍,不能保证以后使用时都能得心应手,但是最起码用到时知道有这么一个功能可以实现,下面对学习进行一下简单的总结: IO流主要用于硬板.内存.键盘等处理 ...

  6. linux ntp时间同步

    linux ntp时间同步 一.搭建时间同步服务器1.编译安装ntp serverrpm -qa | grep ntp若没有找到,则说明没有安装ntp包,从光盘上找到ntp包,使用rpm -Uvh n ...

  7. ubuntu 制作deb 包

    ubuntu下打包制作deb安装包 http://www.th7.cn/system/lin/201406/61012.shtml   2014-06-22 20:16:45CSDN-yangbing ...

  8. yii2高级版账号密码问题

    yii2高级版默认后台没有密码,生成账号密码步骤: 1. CREATE TABLE `user` ( `id` int(11) NOT NULL AUTO_INCREMENT, `username` ...

  9. freebsd上安装nginx+php记录

    参考文章 https://wiki.freebsdchina.org/faq/ports http://www.vpsee.com/2014/04/install-nginx-php-apc-mysq ...

  10. rpc rmi http

    1.RPC与RMI (1)RPC 跨语言,而 RMI只支持Java. (2)RMI 调用远程对象方法,允许方法返回 Java 对象以及基本数据类型,而RPC 不支持对象的概念,传送到 RPC 服务的消 ...