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

Gmail中DeepLink无法唤起App,浏览器中正常,求技术解答

从Gmail点击DeepLink无法唤起Android应用的问题

我们正在为Android应用实现从Gmail跳转的DeepLink功能,已在Manifest中配置了如下代码:

<activity
    android:name="io.fetchcar.archapp.MainActivity"
    android:exported="true">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>

    <intent-filter android:label="@string/filter_view_fetch">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="fetch" />
    </intent-filter>

</activity>

同时在Gmail的邮件中添加了如下HTML按钮:

<a href="fetch://" class="link" target="_blank" alt="Fetch App">Fetch A Car Now</a>

但点击Gmail中的按钮无法唤起应用,而在浏览器中打开包含该按钮的网页时,点击却能正常唤起应用。想问Gmail对通过DeepLink唤起应用是否存在限制?


Gmail确实会对自定义Scheme的DeepLink进行拦截,这是出于安全和用户体验的考量,防止恶意链接未经用户确认就唤起应用。针对这个问题,可以尝试以下几种解决方案:

  • 改用Android App Links
    这是Google官方推荐的方案,能让Gmail直接识别并唤起应用,无需额外确认。需要做两处修改:

    1. 给Manifest中的DeepLink intent-filter添加android:autoVerify="true",同时补充http/https scheme和对应的域名:
    <intent-filter android:label="@string/filter_view_fetch" 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="fetch" />
        <data android:scheme="https" android:host="你的域名.com" />
    </intent-filter>
    
    1. 在你的域名下的.well-known目录中放置assetlinks.json文件,验证应用与域名的关联,格式示例:
    [{
      "relation": ["delegate_permission/common.handle_all_urls"],
      "target": {
        "namespace": "android_app",
        "package_name": "io.fetchcar.archapp",
        "sha256_cert_fingerprints": ["你的应用签名SHA256指纹"]
      }
    }]
    
  • 通过网页中转唤起
    如果暂时无法配置App Links,可以先让Gmail跳转到你的官网页面,再由页面的JS代码唤起DeepLink。修改邮件中的HTML链接:

    <a href="https://你的域名.com/app-redirect" class="link" target="_blank" alt="Fetch App">Fetch A Car Now</a>
    

    然后在app-redirect页面中添加以下JS代码:

    // 尝试唤起应用
    window.location.href = 'fetch://';
    // 如果1秒内未唤起,引导用户下载应用
    setTimeout(() => {
        window.location.href = 'https://play.google.com/store/apps/details?id=io.fetchcar.archapp';
    }, 1000);
    
  • 检查Gmail安全设置
    部分版本的Gmail有“链接保护”功能,会对未知链接进行扫描拦截。可以让用户检查Gmail设置,确认是否开启了相关功能,尝试临时关闭后再测试。


内容的提问来源于stack exchange,提问作者Ali

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.12 17:10:23