Instance Method

webView(_:didReceive:completionHandler:)

Called when the web view needs to respond to an authentication challenge.

Declaration

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

Parameters

webView

The web view receiving the authentication challenge.

challenge

The authentication challenge.

completionHandler

A block to invoke to respond to the challenge. The disposition parameter must be one of the constants of the enumerated type URLSession.AuthChallengeDisposition. When disposition is URLSession.AuthChallengeDisposition.useCredential, the credential parameter specifies the credential to use, or nil to continue without a credential.

Discussion

If you do not implement this method, the web view will respond to the authentication challenge with the URLSession.AuthChallengeDisposition.rejectProtectionSpace disposition.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software