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://
,
func webView(_ webView: WKWebView,
createWebViewWith configuration: WKWebViewConfiguration,
for navigationAction: WKNavigationAction,
windowFeatures: WKWindowFeatures) -> WKWebView? {
if navigationAction.targetFrame == nil, let url = navigationAction.request.url, let scheme = url.scheme {
if ["http", "https", "mailto"].contains(where: { $0.caseInsensitiveCompare(scheme) == .orderedSame }) {
UIApplication.shared.openURL(url)
}
}
return nil
}