javascript - 如何通过单击 anchor 标记链接到已安装的应用程序?

标签 javascript php jquery html

我正在用 php 做项目。为了进行电子邮件验证,我将向用户发送一封电子邮件,

Hi, 

We need to make sure you are human. Please verify your email and get started using your Website account. 

http://siteurl/email-verification/cc6560387c1111558bf5424046f2dc2b

当用户单击给定链接时,他将重定向到浏览器页面,消息如下:

Your account is actived.

Click here to go back to application.

但是现在我在重定向到我的 Android 应用程序时遇到了问题。 我不知道如何将用户重定向回我的应用程序。现在我尝试使用以下代码将用户重定向到 facebook,

<a href="https://facebook.com/me" data-applink="fb://profile">Click here</a> to go back to application.

<script>
    $('a[data-applink]').applink();
</script>

但它在浏览器中打开 Facebook,而不是 Facebook 应用程序。 有什么办法可以做到这一点吗?

我做过类似的事情, 其中 EngageV1 是我的应用程序名称

<div id="main" style="text-align: center; color: #787878">
        <h2><?php echo $msg; ?></h2>
        <a href="https://play.google.com/store/apps/details?id=engage.app.v1&ah=yIEhKqv-vh5CnjQrIULLeVouxkA" class="large-screen">Click here</a> to go back to application.
        <a href="EngageV1://" class="small-screen">Click here</a> to go back to application.
    </div>


<script>
    setTimeout(function () { window.location = "https://play.google.com/store/apps/details?id=engage.app.v1&ah=yIEhKqv-vh5CnjQrIULLeVouxkA"; }, 25);
    window.location = "EngageV1://";
</script>

最佳答案

您需要使用App Links.

您需要做的是创建一个与 Android 应用程序的事件关联的 URL,这样当用户打开该链接时,可以在应用程序本身中打开该链接。

查看 Android 文档,了解有关如何添加应用程序链接并将其附加到 Web URL 的详细信息。

https://developer.android.com/training/app-links/index.html

Android 6.0 (API level 23) and higher allow an app to designate itself as the default handler of a given type of link.

So users with API level lower then 23 will have to select the opening app of a Web URL. At least once.

关于javascript - 如何通过单击 anchor 标记链接到已安装的应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37694948/

相关文章:

javascript - 如何从该函数中获取函数名称?

javascript - CSS/JS 仅使其中一个 div 调整大小/滚动到固定页脚

javascript - 避免字符串中的问号

php - 正则表达式断言 - 两者兼而有之

javascript - 每次编辑器加载时都关注文本字段

jquery - 使用 Bootstrap 面板类的正确方法?

javascript - 单击按钮刷新页面 div

javascript - 创建多个<audio>元素以防止剪切

javascript - 来自 php 文件的 xampp 脚本不会转移到 html 文件

php - 被零除