Instance Method


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


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



The web view receiving the authentication challenge.


The authentication challenge.


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.


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