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

Android13+ React Native推送通知Accept按钮Deep Linking失效问题

解决Android 13+推送通知Accept按钮无法触发Deep Link的问题

问题根源

Android 13(API 33)及以上版本新增了**蹦床活动(Trampoline Activity)**限制,禁止从通知动作间接启动其他活动。你看到的Logcat报错Indirect notification activity start (trampoline) from com.pickyassist.tb blocked就是这个限制导致的——当前推送通知的Accept按钮触发了中间跳转的蹦床逻辑,被系统直接拦截。而Android 12及以下版本没有这个限制,因此可以正常工作。

解决方案

1. 直接配置PendingIntent指向目标页面

修改推送通知的点击动作逻辑,让PendingIntent直接启动处理Deep Link的目标Activity,跳过中间跳转环节:

// 示例代码(Android原生层)
Intent deepLinkIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("your-deep-link-scheme://target-page"));
deepLinkIntent.setPackage(getPackageName());
deepLinkIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);

// Android 12+必须指定IMMUTABLE/MUTABLE标记
PendingIntent pendingIntent = PendingIntent.getActivity(
    this,
    0,
    deepLinkIntent,
    PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT
);

2. 修正Firebase Messaging通知处理逻辑

如果你用FCM发送通知,需确保:

  • 通知payload中的click_action字段直接指向你注册的Deep Link Activity(而非中间跳转页)
  • 避免在onMessageReceived中通过服务、广播间接启动页面,这种操作会触发蹦床限制

3. 检查AndroidManifest的Deep Link配置

确保处理Deep Link的Activity已正确注册,且满足Android 12+的exported要求:

<activity
    android:name=".YourDeepLinkActivity"
    android:exported="true">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <!-- 替换为你的Deep Link Scheme -->
        <data android:scheme="pickyassist" />
    </intent-filter>
</activity>

4. 移除中间跳转逻辑

检查代码中是否存在从通知点击后先启动SplashActivity或其他过渡页,再跳转至目标页面的逻辑——这种间接跳转正是被Android 13+拦截的蹦床行为,需改为直接启动目标页面。

5. 确认PendingIntent标记合规

Android 12(API 31)及以上版本要求PendingIntent必须指定FLAG_IMMUTABLE或FLAG_MUTABLE:

  • 若Deep Link内容无需动态更新,使用FLAG_IMMUTABLE
  • 若需要修改Intent参数,使用FLAG_MUTABLE

额外检查点

  • 确认react-native-push-notification已更新至兼容Android 13+的版本(当前你的版本是8.1.1,可查看官方仓库是否有更新)
  • 验证推送payload中的Deep Link参数是否正确,客户端是否能正确解析并处理

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.20 10:54:52