ios - WKWebview 点击电话 href=“tel:xxx”没有效果是为什么?
大家讲道理
大家讲道理 2017-04-17 17:59:54
0
7
1773

WKWebview 点击电话 href=“tel:xxx”没有效果是为什么?

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(7)
小葫芦

When you click the call button, you need to return
decisionHandler(WKNavigationActionPolicyAllow) in this
-(void)webView:(WKWebView )webView decidePolicyForNavigationAction:(WKNavigationAction )navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandlerproxy method );
Then in the proxy method - (void)webView:(WKWebView )webView didStartProvisionalNavigation:(WKNavigation )navigation
Judge [webView.URL absoluteString]

Paste the code:

//If you do not implement this proxy method, urls such as phone calls will be blocked by default
-(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;

    }
    }

Peter_Zhu

tel://xxx?

左手右手慢动作

Excuse me, has this problem been solved? I also encountered the same problem

PHPzhong

Is it because of the Chinese colon used?
Similar to <a href="tel:xxx">xxx</a>, there will be no problem.

黄舟

Try this

<a href="tel: + 1 + 电话号码>电话号码</a>
大家讲道理

Colon: Chinese is used:)

PHPzhong

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

In this method, print the value of navigationAction.navigationType. If it is 0, special treatment is required

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template