iOS-WKWebView拨打电话号码

h5的拨打电话代码是

#Javascript
移动WEB页面JS一键拨打号码咨询功能  

// 处理拨打电话以及Url跳转等等

  #Object-C
   self.webView.navigationDelegate = self;

- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {  
    NSURL *URL = navigationAction.request.URL;  
    NSString *scheme = [URL scheme];  
    if ([scheme isEqualToString:@"tel"]) {  
        NSString *resourceSpecifier = [URL resourceSpecifier];  
        NSString *callPhone = [NSString stringWithFormat:@"telprompt://%@", resourceSpecifier];  
        /// 防止iOS 10及其之后,拨打电话系统弹出框延迟出现  
        dispatch_async(dispatch_get_global_queue(0, 0), ^{  
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:callPhone]];  
        });  
    }  
    decisionHandler(WKNavigationActionPolicyAllow);  
} 

你可能感兴趣的:(iOS-WKWebView拨打电话号码)