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

如何构建Intent跳转Firebase Android测试应用的新版本下载详情页

如何通过Intent直接跳转至Firebase App Tester的指定版本详情页?

我们的内部用户使用Firebase App Tester测试应用的staging构建版本,希望通过启动Intent直接跳转至该应用内的对应页面。现有强制更新逻辑会跳转至Google Play商店,但staging环境下该逻辑无法生效,因此需要直接引导用户进入Firebase App Tester,理想状态是打开显示新版本可下载的详情页。

我已分析该应用的APK,得到以下配置:

<activity
    android:theme="@ref/0x7f130129"
    android:name="dev.firebase.appdistribution.main.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: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" />
        <data
            android:host="appdistribution.firebase.google.com" />
        <data
            android:pathPrefix="/testerapps/" />
    </intent-filter>

    <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" />
        <data
            android:host="appdistribution.firebase.google.com" />
        <data
            android:pathPattern="/testerapps/.*/releases/.*" />
    </intent-filter>

    <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" />
        <data
            android:host="appdistribution.firebase.google.com" />
        <data
            android:pathPrefix="/accept/" />
    </intent-filter>
</activity>

我推测对应的Intent应该匹配以下配置:

<data
    android:scheme="https" />
<data
    android:host="appdistribution.firebase.google.com" />
<data
    android:pathPattern="/testerapps/.*/releases/.*" />

但始终无法构建出能正确打开应用并跳转至目标页面的Intent,求解决建议。


解决建议

  1. 构建符合匹配规则的Intent
    构造ACTION_VIEW类型的Intent,数据部分严格匹配https://appdistribution.firebase.google.com/testerapps/[你的应用ID]/releases/[版本ID]格式的URL,路径要完全符合pathPattern的规则:/testerapps/.*/releases/.*。

    Kotlin示例代码:

    val intent = Intent(Intent.ACTION_VIEW).apply {
        data = Uri.parse("https://appdistribution.firebase.google.com/testerapps/your-app-id/releases/your-release-id")
        addCategory(Intent.CATEGORY_DEFAULT)
        addCategory(Intent.CATEGORY_BROWSABLE)
        // 强制跳转至Firebase App Tester,避免打开浏览器
        setPackage("dev.firebase.appdistribution")
    }
    if (intent.resolveActivity(packageManager) != null) {
        startActivity(intent)
    }
    

    Java示例代码:

    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse("https://appdistribution.firebase.google.com/testerapps/your-app-id/releases/your-release-id"));
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.addCategory(Intent.CATEGORY_BROWSABLE);
    // 强制跳转至Firebase App Tester
    intent.setPackage("dev.firebase.appdistribution");
    if (getPackageManager().resolveActivity(intent, 0) != null) {
        startActivity(intent);
    }
    
  2. 关键注意事项

    • 指定包名:添加setPackage("dev.firebase.appdistribution")可强制Intent跳转至目标应用,避免系统弹出选择器或打开浏览器。
    • 路径准确性:URL中的your-app-id和your-release-id必须是Firebase控制台中对应应用和版本的真实ID,可从Firebase App Distribution网页版的版本详情页地址栏获取。
    • 快速验证:使用adb命令在测试设备上验证Intent有效性:
      adb shell am start -a android.intent.action.VIEW -d "https://appdistribution.firebase.google.com/testerapps/your-app-id/releases/your-release-id" -n dev.firebase.appdistribution/.main.MainActivity
      
  3. 备选兼容方案
    如果直接跳转版本详情页失败,可先跳转至应用列表页(匹配pathPrefix="/testerapps/"规则),URL为https://appdistribution.firebase.google.com/testerapps/your-app-id,用户可从列表中找到对应版本,兼容性更高。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.03 06:56:55