解决WKWebView加载的H5,无法调用拨打电话功能

UIWebView加载的H5,可以调用;但是WKWebView就是不行,可以在WKWebView的WKNavigationDelegate代理方法处理,代码如下:

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

- (void)webView:(WKWebView*)webView decidePolicyForNavigationAction:(WKNavigationAction*)navigationAction decisionHandler:(void(^)(WKNavigationActionPolicy))decisionHandler {

    NSURL*URL = navigationAction.request.URL;

    NSString*scheme = [URLscheme];

    if([schemeisEqualToString:@"tel"]) {

        NSString*resourceSpecifier = [URLresourceSpecifier];

        NSString*callPhone = [NSStringstringWithFormat:@"telprompt://%@", resourceSpecifier];

        /// 防止iOS 10及其之后,拨打电话系统弹出框延迟出现

        dispatch_async(dispatch_get_global_queue(0, 0), ^{

            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:callPhone]];

        });

    }

    decisionHandler(WKNavigationActionPolicyAllow);

}

你可能感兴趣的:(解决WKWebView加载的H5,无法调用拨打电话功能)