2016-06-27 29 views
-1

我想在我的WebView項目中使用Touch ID。如果我的webview加載某個url,我想顯示touchid認證。我的問題是如何在驗證成功後暫停和恢復加載?如果TouchID成功,則恢復WebView

我有方法「shouldStartLoadWithRequest」這下面的代碼:

if([url isEqualToString:@"...=thisismyurl"]){ LAContext *myContext = [[LAContext alloc] init]; 
    NSError *authError = nil; 
    NSString *myLocalizedReasonString = @"Please Authentificate"; 

    if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError]) { 
     [myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics 
        localizedReason:myLocalizedReasonString 
          reply:^(BOOL success, NSError *error) { 
           if (success) { 
            // User authenticated successfully, take appropriate action 
            ???? 
           } else { 
            // User did not authenticate successfully, look at error and take appropriate action 
            NSLog(@"NEIN"); 
           } 
          }]; 
    }} 

重要信息:該解決方案是我的最後評論!

+0

標題有誤導性。如果你的問題是暫停webview加載網址,那麼爲什麼你的問題在webview中被稱爲touch ID身份驗證? –

+0

僅供參考,您可以使用stopLoading和startLoading,isLoading方法爲webview。 –

+0

你是對的標題!是的,我現在用停下來測試它(你確定嗎?啓動加載不是一個有效的方法)。當我使用loadRequest時,我一次又一次地看到TouchID提示 – NoBody

回答

0

我擁有它!現在我有一個如果之前。在這種情況下,程序可以看到這個呼叫是否來自一個按鈕的例子。這是我的解決方案:

if (navigationType == UIWebViewNavigationTypeFormSubmitted) { ... }