Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

Added handler for tel protocol #171

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
id="com.telerik.plugins.wkwebview"
version="0.6.1">
version="0.6.2">

<name>WKWebView Polyfill</name>

Expand Down
25 changes: 25 additions & 0 deletions src/ios/MyMainViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down