iOS 8.0新特性之指纹解锁
2017-03-12 00:30
483 查看
iOS 8.0提供了指纹解锁,使用它我们可以轻松进行当前手机用户指纹的确认。
在使用指纹解锁时需要导入头文件
1、初始化LAContext对象
2、对是否支持指纹解锁进行判定
返回值为当前设备是否支持指纹解锁的状态值
3、支持指纹解锁进行指纹解锁的验证
完整代码:
本人使用模拟器,未能达到理想效果,最好亲自体验。
在使用指纹解锁时需要导入头文件
#import <LocalAuthentication/LocalAuthentication.h>
1、初始化LAContext对象
LAContext *context = [LAContext new];
2、对是否支持指纹解锁进行判定
[context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:NULL]
返回值为当前设备是否支持指纹解锁的状态值
3、支持指纹解锁进行指纹解锁的验证
[context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:@"请输入手势密码" reply:^(BOOL success, NSError * _Nullable error) { //success 为1 表示密码正确 if (success) { NSLog(@"手势密码成功"); }else{ // Authentication was not successful, because user failed to provide valid credentials. //LAErrorAuthenticationFailed 指纹无法识别 // Authentication was canceled by user (e.g. tapped Cancel button). //LAErrorUserCancel 用户点击取消 // Authentication was canceled, because the user tapped the fallback button (Enter Password). //LAErrorUserFallback 用户点击输入密码 // Authentication was canceled by system (e.g. another application went to foreground). //LAErrorSystemCancel 系统取消(如电话) // Authentication could not start, because passcode is not set on the device. //LAErrorPasscodeNotSet 用户没有设置指纹 // Authentication could not start, because Touch ID is not available on the device. //LAErrorTouchIDNotAvailable 不能在此设备上使用指纹 NSLog(@"手势密码失败"); } }];
完整代码:
//iOS 8.0提供的方法
LAContext *context = [LAContext new];
if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:NULL]) {
NSLog(@"此设备支持指纹");
[context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:@"请输入手势密码" reply:^(BOOL success, NSError * _Nullable error) { //success 为1 表示密码正确 if (success) { NSLog(@"手势密码成功"); }else{ // Authentication was not successful, because user failed to provide valid credentials. //LAErrorAuthenticationFailed 指纹无法识别 // Authentication was canceled by user (e.g. tapped Cancel button). //LAErrorUserCancel 用户点击取消 // Authentication was canceled, because the user tapped the fallback button (Enter Password). //LAErrorUserFallback 用户点击输入密码 // Authentication was canceled by system (e.g. another application went to foreground). //LAErrorSystemCancel 系统取消(如电话) // Authentication could not start, because passcode is not set on the device. //LAErrorPasscodeNotSet 用户没有设置指纹 // Authentication could not start, because Touch ID is not available on the device. //LAErrorTouchIDNotAvailable 不能在此设备上使用指纹 NSLog(@"手势密码失败"); } }];
}
else{
NSLog(@"此设备不支持指纹");
}
本人使用模拟器,未能达到理想效果,最好亲自体验。
相关文章推荐
- iOS 指纹解锁
- iOS开发实现TouchID指纹解锁
- iOS开发之指纹解锁
- ios 指纹解锁
- iOS 指纹解锁
- 论坛源码推荐(6月10日):iOS 8指纹解锁 用Swift语言编写的JokeClient和FanFan
- iOS指纹识别(解锁)
- iOS之指纹解锁
- iOS开发 手势密码解锁和指纹TouchID解锁
- iOS指纹解锁,几行代码解决,特简单
- iOS 指纹解锁 验证TouchID
- iOS 指纹解锁
- iOS实现启动引导页与指纹解锁的方法详解
- iOS手势解锁和指纹解锁
- iOS开发之iOS8指纹解锁
- iOS 指纹解锁
- iOS 指纹解锁验证TouchID功能
- iOS开发之指纹解锁
- iOS 指纹解锁
- iOS开发实现TouchID指纹解锁