In my case, I have website (that includes 3 button shared for Line, Twitter, Facebook). Everything was working well until I check the action link clicked inside webView.
My code have jumped from webView to shared links even I not click inside webView. (when it first load webView).
My code:
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
if let urlMain = navigationAction.request.url {
if urlMain.host == "line.me" { decisionHandler(WKNavigationActionPolicy.cancel)
UIApplication.shared.openURL(urlMain)
}
decisionHandler(WKNavigationActionPolicy.allow)
}
Can you help me find the solution? All I want is when I first present webView, it not navigate to shared links, and it only work when I click on button shared in webView. Thanks you!