Posts

Showing posts with the label Uiwebview

Capture Redirect Url In Wkwebview In Ios

Answer : Use this WKNavigationDelegate method public func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Swift.Void) { if(navigationAction.navigationType == .other) { if navigationAction.request.url != nil { //do what you need with url //self.delegate?.openURL(url: navigationAction.request.url!) } decisionHandler(.cancel) return } decisionHandler(.allow) } Hope this helps (This answers the slightly more general question of how to detect a URL redirection in WKWebView, which is the search that lead me to this page.) Short answer Use WKNavigationDelegate 's webView(_:didReceiveServerRedirectForProvisionalNavigation:) function and examine WKWebView 's URL property. Longer answer There are a couple of places you could detect a server-side redirect. On iOS 10.3...