iOS8使用TouchID

來源:互聯網
上載者:User

標籤: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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.