diff --git a/README.md b/README.md index fe261ef..f3aec38 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ It's a screenshot of the [demo app](demo/index.html). From npm ``` -$ cordova plugin add @telerik/cordova-plugin-wkwebview +$ cordova plugin add https://github.com/AlBusso/WKWebView.git $ cordova prepare ``` diff --git a/plugin.xml b/plugin.xml index c4999b0..5e748a5 100755 --- a/plugin.xml +++ b/plugin.xml @@ -1,7 +1,7 @@ + version="0.6.2"> WKWebView Polyfill diff --git a/src/ios/MyMainViewController.m b/src/ios/MyMainViewController.m index e6c318c..9a56d1f 100755 --- a/src/ios/MyMainViewController.m +++ b/src/ios/MyMainViewController.m @@ -575,6 +575,31 @@ - (void)webView:(WKWebView *)webView didFailNavigation:(WKNavigation *)navigatio - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler { + if(webView != self.wkWebView) { + decisionHandler(WKNavigationActionPolicyAllow); + return; + } + + UIApplication *app = [UIApplication sharedApplication]; + NSURL *url = navigationAction.request.URL; + + if (!navigationAction.targetFrame) { + if ([app canOpenURL:url]) { + [app openURL:url]; + decisionHandler(WKNavigationActionPolicyCancel); + return; + } + } + if ([url.scheme isEqualToString:@"tel"]) + { + if ([app canOpenURL:url]) + { + [app openURL:url]; + decisionHandler(WKNavigationActionPolicyCancel); + return; + } + } + if (!navigationAction.targetFrame) { // links with target="_blank" need to open outside the app, but WKWebView doesn't allow it currently NSURL *url = navigationAction.request.URL;