Interface WKNavigationDelegate


  • public interface WKNavigationDelegate
    A class conforming to the WKNavigationDelegate protocol can provide methods for tracking progress for main frame navigations and for deciding policy for main frame and subframe navigations.
    • Method Detail

      • webViewDecidePolicyForNavigationActionDecisionHandler

        default void webViewDecidePolicyForNavigationActionDecisionHandler​(WKWebView webView,
                                                                           WKNavigationAction navigationAction,
                                                                           WKNavigationDelegate.Block_webViewDecidePolicyForNavigationActionDecisionHandler decisionHandler)
        Decides whether to allow or cancel a navigation. If you do not implement this method, the web view will load the request or, if appropriate, forward it to another application.
        Parameters:
        webView - The web view invoking the delegate method.
        navigationAction - Descriptive information about the action triggering the navigation request.
        decisionHandler - The decision handler to call to allow or cancel the navigation. The argument is one of the constants of the enumerated type WKNavigationActionPolicy.
      • webViewDecidePolicyForNavigationResponseDecisionHandler

        default void webViewDecidePolicyForNavigationResponseDecisionHandler​(WKWebView webView,
                                                                             WKNavigationResponse navigationResponse,
                                                                             WKNavigationDelegate.Block_webViewDecidePolicyForNavigationResponseDecisionHandler decisionHandler)
        Decides whether to allow or cancel a navigation after its response is known. If you do not implement this method, the web view will allow the response, if the web view can show it.
        Parameters:
        webView - The web view invoking the delegate method.
        navigationResponse - Descriptive information about the navigation response.
        decisionHandler - The decision handler to call to allow or cancel the navigation. The argument is one of the constants of the enumerated type WKNavigationResponsePolicy.
      • webViewDidCommitNavigation

        default void webViewDidCommitNavigation​(WKWebView webView,
                                                WKNavigation navigation)
        Invoked when content starts arriving for the main frame.
        Parameters:
        webView - The web view invoking the delegate method.
        navigation - The navigation.
      • webViewDidFailNavigationWithError

        default void webViewDidFailNavigationWithError​(WKWebView webView,
                                                       WKNavigation navigation,
                                                       NSError error)
        Invoked when an error occurs during a committed main frame navigation.
        Parameters:
        webView - The web view invoking the delegate method.
        navigation - The navigation.
        error - The error that occurred.
      • webViewDidFailProvisionalNavigationWithError

        default void webViewDidFailProvisionalNavigationWithError​(WKWebView webView,
                                                                  WKNavigation navigation,
                                                                  NSError error)
        Invoked when an error occurs while starting to load data for the main frame.
        Parameters:
        webView - The web view invoking the delegate method.
        navigation - The navigation.
        error - The error that occurred.
      • webViewDidFinishNavigation

        default void webViewDidFinishNavigation​(WKWebView webView,
                                                WKNavigation navigation)
        Invoked when a main frame navigation completes.
        Parameters:
        webView - The web view invoking the delegate method.
        navigation - The navigation.
      • webViewDidReceiveAuthenticationChallengeCompletionHandler

        default void webViewDidReceiveAuthenticationChallengeCompletionHandler​(WKWebView webView,
                                                                               NSURLAuthenticationChallenge challenge,
                                                                               WKNavigationDelegate.Block_webViewDidReceiveAuthenticationChallengeCompletionHandler completionHandler)
        Invoked when the web view needs to respond to an authentication challenge. If you do not implement this method, the web view will respond to the authentication challenge with the NSURLSessionAuthChallengeRejectProtectionSpace disposition.
        Parameters:
        webView - The web view that received the authentication challenge.
        challenge - The authentication challenge.
        completionHandler - The completion handler you must invoke to respond to the challenge. The disposition argument is one of the constants of the enumerated type NSURLSessionAuthChallengeDisposition. When disposition is NSURLSessionAuthChallengeUseCredential, the credential argument is the credential to use, or nil to indicate continuing without a credential.
      • webViewDidReceiveServerRedirectForProvisionalNavigation

        default void webViewDidReceiveServerRedirectForProvisionalNavigation​(WKWebView webView,
                                                                             WKNavigation navigation)
        Invoked when a server redirect is received for the main frame.
        Parameters:
        webView - The web view invoking the delegate method.
        navigation - The navigation.
      • webViewDidStartProvisionalNavigation

        default void webViewDidStartProvisionalNavigation​(WKWebView webView,
                                                          WKNavigation navigation)
        Invoked when a main frame navigation starts.
        Parameters:
        webView - The web view invoking the delegate method.
        navigation - The navigation.
      • webViewWebContentProcessDidTerminate

        default void webViewWebContentProcessDidTerminate​(WKWebView webView)
        Invoked when the web view's web content process is terminated.
        Parameters:
        webView - The web view whose underlying web content process was terminated.
      • webViewDecidePolicyForNavigationActionPreferencesDecisionHandler

        default void webViewDecidePolicyForNavigationActionPreferencesDecisionHandler​(WKWebView webView,
                                                                                      WKNavigationAction navigationAction,
                                                                                      WKWebpagePreferences preferences,
                                                                                      WKNavigationDelegate.Block_webViewDecidePolicyForNavigationActionPreferencesDecisionHandler decisionHandler)
        Decides whether to allow or cancel a navigation. If you implement this method, -webView:decidePolicyForNavigationAction:decisionHandler: will not be called.
        Parameters:
        webView - The web view invoking the delegate method.
        navigationAction - Descriptive information about the action triggering the navigation request.
        preferences - The default set of webpage preferences. This may be changed by setting defaultWebpagePreferences on WKWebViewConfiguration.
        decisionHandler - The policy decision handler to call to allow or cancel the navigation. The arguments are one of the constants of the enumerated type WKNavigationActionPolicy, as well as an instance of WKWebpagePreferences.
      • webViewAuthenticationChallengeShouldAllowDeprecatedTLS

        default void webViewAuthenticationChallengeShouldAllowDeprecatedTLS​(WKWebView webView,
                                                                            NSURLAuthenticationChallenge challenge,
                                                                            WKNavigationDelegate.Block_webViewAuthenticationChallengeShouldAllowDeprecatedTLS decisionHandler)
        Invoked when the web view is establishing a network connection using a deprecated version of TLS.
        Parameters:
        webView - The web view initiating the connection.
        challenge - The authentication challenge.
        decisionHandler - The decision handler you must invoke to respond to indicate whether or not to continue with the connection establishment.