You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何避免Android深度链接在未安装APP时跳转至Google Play商店

解决方案

网站端处理(无需修改Android应用)

通过JavaScript检测应用是否唤起成功,避免未安装时跳转Google Play:

  • 不要直接用<a>标签跳转intent链接,改用JS逻辑触发
  • 核心思路:触发intent跳转后,通过定时器检查页面可见状态,判断应用是否唤起成功

代码示例:

function triggerAppOpen() {
  const packageName = "<PACKAGE_NAME>";
  const intentLink = `intent://#Intent;package=${packageName};action=android.intent.action.VIEW;category=android.intent.category.BROWSABLE;scheme=https;end`;
  
  const startTimestamp = Date.now();
  // 尝试唤起应用
  window.location.href = intentLink;
  
  // 1秒后检查是否唤起成功
  setTimeout(() => {
    // 若页面仍可见且时间差小于1.5秒,说明应用未唤起
    if (Date.now() - startTimestamp < 1500 && document.visibilityState === "visible") {
      // 留在当前页面,可添加"应用未安装"的提示文案
      console.log("应用未安装,停留在浏览器");
      // 如需阻止意外跳转,可执行 window.history.back() 或保持当前页面状态
    }
  }, 1000);
}

调用这个函数即可实现需求,兼容性覆盖主流Android浏览器。

Android端处理(原生优化方案)

如果想用https://格式的intent链接,需在应用和网站端完成两处配置:

  1. AndroidManifest配置
    在目标Activity中添加带autoVerify的intent-filter,关联你的网站域名:
<activity android:name=".YourTargetActivity">
  <intent-filter android:autoVerify="true">
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <!-- 替换为你的网站域名 -->
    <data android:scheme="https" android:host="your-domain.com" />
  </intent-filter>
</activity>
  1. 网站配置assetlinks.json
    在网站根目录的.well-known文件夹下创建assetlinks.json文件,内容如下(替换为你的应用信息):
[{
  "relation": ["delegate_permission/common.handle_all_urls"],
  "target": {
    "namespace": "android_app",
    "package_name": "<PACKAGE_NAME>",
    "sha256_cert_fingerprints": ["你的应用签名SHA256指纹"]
  }
}]

配置完成后,https://格式的intent链接可直接唤起应用;未安装时,浏览器会加载对应的https链接页面,你可以在该页面展示引导安装的内容,自然留在浏览器中。


内容的提问来源于stack exchange,提问作者Shivendra Pratap Singh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.04 23:25:19