WKWebview 点击电话 href=“tel:xxx”没有效果是为什么?
光阴似箭催人老,日月如移越少年。
在点击打电话这个按钮的时候需要在这个-(void)webView:(WKWebView )webView decidePolicyForNavigationAction:(WKNavigationAction )navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler代理方法中返回decisionHandler(WKNavigationActionPolicyAllow);然后在代理方法中- (void)webView:(WKWebView )webView didStartProvisionalNavigation:(WKNavigation )navigation判断[webView.URL absoluteString]
贴上代码:
//如果不实现这个代理方法,默认会屏蔽掉打电话等url-(void)webView:(WKWebView )webView decidePolicyForNavigationAction:(WKNavigationAction )navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {
decisionHandler(WKNavigationActionPolicyAllow);
}
(void)webView:(WKWebView )webView didStartProvisionalNavigation:(WKNavigation )navigation{
NSString *path=[YKBDateHelper convertNull:[webView.URL absoluteString]]; NSString * newPath = [path lowercaseString];
if ([newPath hasPrefix:@"sms:"] || [newPath hasPrefix:@"tel:"]) {
UIApplication * app = [UIApplication sharedApplication]; if ([app canOpenURL:[NSURL URLWithString:newPath]]) { [app openURL:[NSURL URLWithString:newPath]]; } return;
}}
tel://xxx?
请问,这个问题解决了吗,我也遇到了同样的问题
是因为用的中文冒号吧?类似于 <a href="tel:xxx">xxx</a>,是不会有问题的。
<a href="tel:xxx">xxx</a>
试试看看这个
<a href="tel: + 1 + 电话号码>电话号码</a>
冒号:用了中文:)
-(void)webView:(WKWebView )webView decidePolicyForNavigationAction:(WKNavigationAction )navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
这个方法中 打印一下navigationAction.navigationType 这个的值 如果是0的话要特殊处理
在点击打电话这个按钮的时候需要在这个
-(void)webView:(WKWebView )webView decidePolicyForNavigationAction:(WKNavigationAction )navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
代理方法中返回decisionHandler(WKNavigationActionPolicyAllow);
然后在代理方法中- (void)webView:(WKWebView )webView didStartProvisionalNavigation:(WKNavigation )navigation
判断[webView.URL absoluteString]
贴上代码:
//如果不实现这个代理方法,默认会屏蔽掉打电话等url
-(void)webView:(WKWebView )webView decidePolicyForNavigationAction:(WKNavigationAction )navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {
}
(void)webView:(WKWebView )webView didStartProvisionalNavigation:(WKNavigation )navigation
{
if ([newPath hasPrefix:@"sms:"] || [newPath hasPrefix:@"tel:"]) {
}
}
tel://xxx?
请问,这个问题解决了吗,我也遇到了同样的问题
是因为用的中文冒号吧?
类似于
<a href="tel:xxx">xxx</a>
,是不会有问题的。试试看看这个
冒号:用了中文:)
-(void)webView:(WKWebView )webView decidePolicyForNavigationAction:(WKNavigationAction )navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
这个方法中 打印一下navigationAction.navigationType 这个的值 如果是0的话要特殊处理