I am trying to get my Hybrid IOS app that uses Swift and WKWebviews to open a link that has target=\"_blank\" or if the URL contains http://,
Swift 4.2
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Swift.Void) {
if navigationAction.navigationType == WKNavigationType.linkActivated {
print("here link Activated!!!")
if let url = navigationAction.request.url {
let shared = UIApplication.shared
if shared.canOpenURL(url) {
shared.open(url, options: [:], completionHandler: nil)
}
}
decisionHandler(.cancel)
}
else {
decisionHandler(.allow)
}
}