標籤:desc nslog not 第三方 style esc 12px zed policy
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