iOS8使用TouchID
2017-05-13 11:37
183 查看
iOS8新增了LocalAuthentication框架,用于TouchID的授权使用。亲測,眼下须要用户的设备支持指纹识别并已设置锁屏,并且实际測试过程中反馈比較慢。不能直接跟第三方账号password绑定,假设须要实现第三方应用直接指纹识别登录,须要在本地存储账号信息,指纹识别通过之后再从本地读取账号信息登录。总之。眼下的指纹识别是跟设备、设备锁屏password绑定的。
測试代码:
測试代码:
///使用TouchID -(void)usingTouchID { LAContext *myContext = [[[LAContext alloc] init] autorelease]; NSError *authError = nil; NSString *myLocalizedReasonString = @"用于指纹登录"; if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError]) { [myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:myLocalizedReasonString reply:^(BOOL success, NSError *error) { if (success) { // User authenticated successfully, take appropriate action NSLog(@"成功"); UIAlertView *alertView = [[[UIAlertView alloc] initWithTitle:@"Suceess" message:@"已通过指纹识别。" delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil] autorelease]; [alertView show]; } else { // User did not authenticate successfully, look at error and take appropriate action NSLog(@"fail with error:%@",error); UIAlertView *alertView = [[[UIAlertView alloc] initWithTitle:@"Failed" message:[error localizedDescription] delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil] autorelease]; [alertView show]; } }]; } else { // Could not evaluate policy; look at authError and present an appropriate message to user NSLog(@"auth with error:%@",authError); UIAlertView *alertView = [[[UIAlertView alloc] initWithTitle:@"Failed" message:[authError localizedDescription] delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil] autorelease]; [alertView show]; } }
相关文章推荐
- IOS8 TouchID使用介绍
- iOS8使用TouchID
- IOS8 TouchID使用介绍
- iOS8 Core Image In Swift:自动改善图像以及内置滤镜的使用
- ios8来了,屏幕更大,准备好使用 iOS Auto Layout了吗?
- ios8下LocationManager及Nsnotification使用
- iOS8指纹识别TouchID
- iOS8中提示框的使用UIAlertController(UIAlertView和UIActionSheet二合一)
- iOS8使用TestFlight进行内部测试功能尝鲜
- 百度地图 iOS SDK - iOS8下使用百度地图SDK定位的问题
- iOS8 Size Classes的理解与使用
- ios8来了,屏幕更大,准备好使用 iOS Auto Layout了吗?
- ios8更新 HealthKit程序错误无法使用
- iOS8指纹识别TouchID
- 关于IOS8的Autolayout特性的理解以及使用
- 苹果5s升级ios8后无法正常使用siri
- ios8来了,屏幕更大,准备好使用 iOS Auto Layout了吗?
- 进入ios8 后使用swift,在使用到UIAlertController(ActionSheet)时适配ipad时挂掉的问题解决方案
- iOS8中提示框的使用UIAlertController(UIAlertView和UIActionSheet二合一)
- iOS8中提示框的使用UIAlertController(UIAlertView和UIActionSheet二合一)