【问题标题】:Mobile phone call or mailto doesn't work at all手机电话或mailto根本不起作用
【发布时间】:2014-12-20 05:04:54
【问题描述】:

我有一个非常小的应用程序:

<!DOCTYPE html>
<html>
<head>
   <title></title>
</head>

<body>
    <a href="mailto:someone@example.com">Send Mail</a>
    <a href="tel: +18543458975">Call</a>

    <button onclick="document.location.href = 'tel:+1-800-555-1234'">Click me</button>
    <button onclick="document.location.href = 'tel:+18543458975'">Click again</button>
</body>
</html>

当我构建并运行它时,链接根本不起作用。

两周前(在另一个应用程序上)这很好用,但现在它在我的旧应用程序上都不起作用。

我的想法用完了!

发生了什么?

【问题讨论】:

    标签: android html cordova mobile ionic-framework


    【解决方案1】:

    我似乎是我正在研究的cordova 3.6版的错误,所以我安装了一个旧版本(3.5),现在它可以正常工作了!

    【讨论】:

      【解决方案2】:

      使用 http/https 以外的协议现在被列入白名单,并且默认被阻止。

      http://cordova.apache.org/announcements/2014/08/04/android-351.html http://cordova.apache.org/announcements/2014/09/08/cordova-361.html

      您只需将 mailto 和 tel 协议添加到白名单即可。

      请参阅http://cordova.apache.org/docs/en/edge/guide_appdev_whitelist_index.md.html 的“外部应用程序白名单”部分,了解从 3.6.0 开始向白名单添加内容的说明。

      由于与此相关的安全漏洞已在 3.5.1 中修复,因此您不想使用 3.5.0,否则您将容易受到攻击并收到来自 Google Play 商店的警告。

      【讨论】:

      • 你是对的。它现在可以工作了。我对移动开发太陌生了,不知道所有这些事情
      • 太棒了 - 将 &lt;access origin="tel:*" launch-external="yes" /&gt;&lt;access origin="mailto:*" launch-external="yes" /&gt; 行添加到 config.xml 可以解决问题。
      【解决方案3】:

      我想随着新版本的发布,情况又发生了变化。

      你必须安装cordova plugin whitelist:

      cordova plugin add cordova-plugin-whitelist
      

      或者如果您想保存对 config.xml 文件的引用:

      cordova plugin add cordova-plugin-whitelist --save
      

      并且您必须将意图添加到您的 config.xml 文件中:

      <allow-intent href="mailto:*" />
      <allow-intent href="tel:*" />
      

      您可以找到更多信息here

      【讨论】:

        猜你喜欢
        • 2021-12-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-09-19
        • 1970-01-01
        • 2011-07-23
        • 1970-01-01
        相关资源
        最近更新 更多