Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ios): Supported tel protocol similar to previous implementation #10793

Merged
merged 5 commits into from
Apr 3, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions iphone/Classes/TiUIWebView.m
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,8 @@ - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(nonnull WK
}
}

NSString *scheme = [navigationAction.request.URL.scheme lowercaseString];

if ([allowedURLSchemes containsObject:navigationAction.request.URL.scheme]) {
if ([[UIApplication sharedApplication] canOpenURL:navigationAction.request.URL]) {
// Event to return url to Titanium in order to handle OAuth and more
Expand All @@ -1025,6 +1027,13 @@ - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(nonnull WK
decisionHandler(WKNavigationActionPolicyCancel);
}
}
} else if (!([scheme hasPrefix:@"http"] || [scheme isEqualToString:@"ftp"] || [scheme isEqualToString:@"file"] || [scheme isEqualToString:@"app"]) && [[UIApplication sharedApplication] canOpenURL:navigationAction.request.URL]) {
// DEPRECATED: Should use the "handleurl" event instead and call openURL on Ti.Platform.openURL instead
DebugLog(@"[WARN] Please use the \"handleurl\" event together with \"allowedURLSchemes\" in Ti.UI.WebView.");
DebugLog(@"[WARN] It returns both the \"url\" and \"handler\" property to open a URL and invoke the decision-handler.");

[[UIApplication sharedApplication] openURL:navigationAction.request.URL];
decisionHandler(WKNavigationActionPolicyCancel);
} else {
decisionHandler(WKNavigationActionPolicyAllow);
}
Expand Down