iOS UIWebView 本身就可以进行拨打电话 那么如果是WKWebView呢,需要这样处理 decidePolicyForNavigationAction
// 发送请求前决定是否要进行跳转
-(void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
{
NSURLRequest * requestUrl = navigationAction.request;
NSURL *url = requestUrl.URL;
NSString * scheme = [url scheme];
if ([scheme isEqualToString:@"tel"]) {
NSString * resourceSpecifier = [url resourceSpecifier];
NSString * cellPhone = [NSString stringWithFormat:@"telprompt://%@",resourceSpecifier];
// 防止iOS 10 以后拨打电话弹框延迟
dispatch_async(dispatch_get_global_queue(0, 0), ^{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:cellPhone]];
});
}
DLog(@"=====webView de URL String -- %@",urlString);
decisionHandler(WKNavigationActionPolicyAllow);
}