get current url of wkwebview (Swift iOS)

I want to get current url of wkwebview. please give the solution. Thanx in advanced...

Replies

You can use: webView.url

NSString *url = [navigationAction.request.URL query];

I think this may work -

extension CCVAddCardViewController: WKUIDelegate, WKNavigationDelegate {
  func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {

    if let urlStr = navigationAction.request.url?.absoluteString {
      print(urlStr)
    }

    decisionHandler(.allow)
  }
}