首页 文章

单击tel:链接时禁止本机对话框

提问于
浏览
1

在点击电话链接时,我一直在寻找抑制移动设备上的对话框无效的方法 .

我们有这个要求用我们网站上的自定义弹出窗口替换iPhone和Android上的现有原生对话框 .

我们有HTML5可供使用,但对于一个基本网站,我们不使用javascript(适用于低功率的WAP手机) .

有没有办法通过我的网站上的HTML来抑制来自浏览器(safari,chrome,firefox?)的手机原生对话框?

谢谢

2 回答

  • 1

    如果你're use case allows you to avoid using the tel: link format, you could put the numbers in something else that looks like a link and then have your webpage treat them however you wish. And to avoid having the browser auto-add links to numbers it thinks are telephone numbers, add the following html tag to your document' s <head> (来自Safari Developer Library):

    <meta name="format-detection" content="telephone=no">
    

    这是否足够或者你的问题还有更多我不理解的问题?

    UPDATE

    进一步澄清,似乎期望的结果是在按下 tel:// 链接时调用本机电话拨号器,但只是抑制拨号之前的用户提示 .

    根据RFC 3966: The tel URI for Telephone Numbers,第11节安全考虑因素:
    "Web clients and similar tools MUST NOT use the " tel " URI to place telephone calls without the explicit consent of the user of that client. Placing calls automatically without appropriate user confirmation may incur a number of risks..."

    因此,虽然仍有可能存在抑制警报的参数,例如 &confirmation=false&alert=no ,但对于每个移动操作系统,它可能没有文档记录且不同 . 我的猜测是它不存在 .

    Possible Workarounds

    根据iOS Developer Library
    "When a user taps a telephone link in a webpage, iOS displays an alert asking if the user really wants to dial the phone number and initiates dialing if the user accepts. When a user opens a URL with the tel scheme in a native application, iOS does not display an alert and initiates dialing without further prompting the user. However, a native application can be configured to display its own alert."

    因此,如果您的用例允许您将网站嵌入 UIWebView 并将其作为iOS应用程序分发,则应该可以禁止警报 .

    根据Android Developer Docs
    “[使用拨号器]要求您的应用程序在您的清单中请求以下权限: <uses-permission id="android.permission.CALL_PHONE" />

    同样,如果您的用例允许您将网站嵌入 android.webkit.WebView 并将其作为Android应用程序分发,则也可以禁止显示警报 .

  • 0

    不确定这是否是你要求的完整规范...据我所知,从过多的时间开始打了几个月,如果操作系统认为它是一个,就没有办法直接压制拨号器对话框电话号码在独立浏览器的页面中单击 .

    我记得它在数据parm中用“Tel:...”广播了一个意图 . 由于供应商的拨号器注意到这一点,你最希望的是让你自己的拨号器也听这个事件...但是然后android会弹出那个恼人的“完整动作”对话框并且他们必须点击你的,然后必须启动另一个拨号器意图 . (然后你会看到你的拦截拨号器吗?)

    正如BigMacAttack指出的那样,您可以通过webkit运行它,将您的标记更改为“tel”以外的其他内容并拦截它 . 同样,如果服务器页面总是可以通过web-kit视图提供,你可以做我在几个Android和iOS应用程序上做的事情:

    // Android flavored
    wv1.setWebViewClient(new WebViewClient() {
    
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
    
            boolean dialMe = false;                 
    
            if (url.indexOf("tel:") > -1) {  // PHONE permissions in AndroidManifest
                                                 // see also DIAL_PHONE
    
                dialMe = myCustomDialerPopup ( Uri.parse(url) ) ; // display YOUR msg.
    
                if ( dialMe = true ) { // launch normal dialer
    
                    Intent i =  new Intent( Intent.ACTION_DIAL, Uri.parse(url) ) ;
                    view.getContext().startActivity(i);  
    
                } else {
                                //// guess they don't want to call - oops marketing failed !
                } 
            }
    
            return true;  // or false to stop navigation.
        } 
    
    }
    

相关问题