Contents

webView(_:didReceive:completionHandler:)

Asks the delegate to respond to an authentication challenge.

Declaration

optional func webView(_ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping @MainActor @Sendable (URLSession.AuthChallengeDisposition, URLCredential?) -> Void)
optional func webView(_ webView: WKWebView, respondTo challenge: URLAuthenticationChallenge) async -> (URLSession.AuthChallengeDisposition, URLCredential?)

Parameters

  • webView:

    The web view that receives the authentication challenge.

  • challenge:

    The authentication challenge.

  • completionHandler:

    A completion handler block to execute with the response. This handler has no return value and takes the following parameters:

    disposition

    The option to use to handle the challenge. For a list of options, see Authchallengedisposition.

    credential

    The credential to use for authentication when the disposition parameter contains the value Usecredential. Specify nil to continue without a credential.

Mentioned in

Discussion

If you don’t implement this method, the web view responds to the authentication challenge with the URLSession.AuthChallengeDisposition.rejectProtectionSpace disposition.

See Also

Responding to authentication challenges