Prakhar Singh
Prakhar Singh

Reputation: 206

Swift WKWebView handle credential popups

I'm working on a Secure Web Browser iOS App. I'm using Swift for development.

My app have a WKWebView for loading URLs. When I'm loading this URL http://relaw.wpengine.com on my App. WKWebView is not showing Credentials Popup.

I have already implemented WKUIDelegate methods

func webView(_ webView: WKWebView, runJavaScriptAlertPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo,
                 completionHandler: @escaping () -> Void) {
 }

 func webView(_ webView: WKWebView, runJavaScriptConfirmPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo,
                 completionHandler: @escaping (Bool) -> Void) {
 }

 func webView(_ webView: WKWebView, runJavaScriptTextInputPanelWithPrompt prompt: String, defaultText: String?, initiatedByFrame frame: WKFrameInfo,
                 completionHandler: @escaping (String?) -> Void) {
}

But, they don't handle this credentials popup.

How can I handle these type of popups in WKWebView

Thanks in Advance

Upvotes: 0

Views: 2511

Answers (1)

Dave Weston
Dave Weston

Reputation: 6635

You need to provide an implementation for the webView(_:didReceive:completionHandler:) method on WKNavigationDelegate. This method is called when the webView receives an authentication challenge.

See this reference: https://developer.apple.com/reference/webkit/wknavigationdelegate/1455638-webview

Upvotes: 2

Related Questions