添加指纹识别功能
2016-01-22 16:37
232 查看
iPhone 5S开始硬件支持指纹识别功能,在iOS 8以后支持指纹识别,今天随意试了试指纹识别功能的识别,写了一个小demo
1.环境
引入头文件
2.创建两个页面
第一个页面添加一个button,用来触发指纹识别的功能
第二个页面就加个label//
指纹识别功能的初步集成还是比较简单的。
1.环境
引入头文件
#import <LocalAuthentication/LocalAuthentication.h>
2.创建两个页面
第一个页面添加一个button,用来触发指纹识别的功能
第二个页面就加个label//
// ViewController.m
// FingerPrint
//
// Created by Silence on 16/1/22.
// Copyright (c) 2016年 Silence. All rights reserved.
//
#import "ViewController.h"
#import "SecondViewController.h"
#import <LocalAuthentication/LocalAuthentication.h>
@interface ViewController ()
{
LAContext * _context;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (IBAction)buttonDidClick:(id)sender {
_context = [[LAContext alloc]init];
BOOL isSupport = [_context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:nil];
if ([UIDevice currentDevice].systemVersion.floatValue < 8.0) {
UIAlertController * alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"当前系统版本不支持指纹识别" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction * action = [UIAlertAction actionWithTitle:@"提示" style:UIAlertActionStyleDefault handler:nil];
[alert addAction:action];
[self presentViewController:alert animated:YES completion:nil];
}else if (!isSupport){
UIAlertController * alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"当前设备不支持指纹识别" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction * action = [UIAlertAction actionWithTitle:@"提示" style:UIAlertActionStyleDefault handler:nil];
[alert addAction:action];
[self presentViewController:alert animated:YES completion:nil];
}else{
[_context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:@"请按手印" reply:^(BOOL success, NSError *error) {
if(success)
{
//这部分处理验证成功的逻辑
SecondViewController * se = [[SecondViewController alloc]init];
[self presentViewController:se animated:YES completion:nil];
}
}];
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
指纹识别功能的初步集成还是比较简单的。
相关文章推荐
- Python程序员都会喜欢的6个库
- Volley源码解析
- iptables 定义规则
- 设计模式学习笔记—代理模式
- eclipse如何debug调试jdk源码
- vmware虚拟机克隆后eth0无法启动的解决方法
- Usb Audio Device Descriptor(8) Type I Format Type Descriptor
- Ionic常用命令行解释
- 【cocos3.9+box2d+tileMap】制作马里奥游戏(一)
- MYSQL 表级锁 行级锁 页面锁区别
- Pinterest月PV百亿的架构设计
- 关于Debug和Release之本质区别的讨论
- 【OpenSource】--TinyHttpD
- 遨游maxthon打开页面一片黑色,百度地图等黑屏解决办法
- python有哪些好的学习资料或者博客
- 做一个思想的码农
- Web项目,F12调试的说明
- 【BZOJ 3144】 [Hnoi2013]切糕
- android edittext 限制输入框小数位数
- 20款jquery下拉导航菜单特效代码分享