-1

i want to use Touch ID in my WebView project. If my webview load a certain url i want show the touchid authentication. My question is how can i pause and resume the loading after the authentification is successful ?

I have this following code in the method "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");
                                }
                            }];
    }}

IMPORTANT: the solution is in my last comment!

NoBody
  • 719
  • 1
  • 6
  • 11
  • The title is misleading. If your question is to pausing the webview load url , then why is your question titled as touch ID authentication in webview ? – Teja Nandamuri Jun 27 '16 at 14:24
  • FYI you can use stopLoading and startLoading,isLoading methods for webview. – Teja Nandamuri Jun 27 '16 at 14:25
  • You´re right sry for the title! Yes i test it now with stoploading (are you sure? startloading is not a valid method). When i use loadRequest i see the TouchID prompt again and again – NoBody Jun 27 '16 at 14:30
  • sry, you can use you can use stopLoading and loadRequest,isLoading methods for webview. – Teja Nandamuri Jun 27 '16 at 14:31
  • Yes, i use loadRequest. But now i see the TouchID prompt again and again. The Problem: i call the loadRequest with the same URL... – NoBody Jun 27 '16 at 14:38
  • when the touch ID prompt is shown call the stopLoading method, and when you dismiss/authenticate the touch ID prompt call loadRequest again. – Teja Nandamuri Jun 27 '16 at 14:40
  • You are loading the same URL and the same branch of code is executed, that is to be expected. You don't have an alternative branch of code for the requests following one of the requests with the same URL that triggered a successful authentication, so it is requested again. I don't see what exactly is the problem here. Also, check the documentation of `evaluatePolicy:localizedReason:reply:`, specifically the last paragraph where they describe what to expect from the following evaluations. – A-Live Jun 27 '16 at 14:55
  • When the User click the next Button in the Webview i want to check the URL and shown the TouchID prompt. If the User authenticate this with success i want to load this URL what he call with the next button before (sry for my english) – NoBody Jun 27 '16 at 15:00
  • Thank you... my solution is in my answer below! – NoBody Jun 27 '16 at 15:16

1 Answers1

0

I have it! Now i have a if before. With this if condition the programm can see if the call come example from a button. This is my Solution:

 if (navigationType == UIWebViewNavigationTypeFormSubmitted) { ... }
NoBody
  • 719
  • 1
  • 6
  • 11