Android后台Firebase推送click_action与intent-filter失效,点击通知无法启动应用
问题分析与解决方案
核心问题原因
你的配置里存在一个关键错误:SplashActivity的android:exported被设置为false。当应用处于后台状态时,Android系统需要启动该Activity响应通知点击事件,但exported="false"会阻止外部组件(包括系统通知服务)启动这个Activity,最终导致点击通知后无任何响应。
具体修复步骤
- 修改Manifest中SplashActivity的exported属性
将android:exported="false"改为android:exported="true",确保系统能正常启动该Activity:
<activity android:name=".ui.activity.login.SplashActivity" android:label="@string/app_name" android:exported="true" android:screenOrientation="portrait"> <intent-filter> <action android:name="DeepLinkHandlerActivity" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
验证click_action匹配性
你的FCM消息中android.notification.click_action的值为"DeepLinkHandlerActivity",与Manifest中SplashActivity的<action>名称完全一致,这部分配置无需修改。额外注意事项
- 针对Android 12及以上版本,所有接收隐式Intent的Activity必须显式设置
android:exported="true",否则会启动失败并抛出异常。 - 若需处理通知携带的参数,可在SplashActivity的
onCreate或onNewIntent方法中通过getIntent().getExtras()获取FCM传递的data数据。
内容的提问来源于stack exchange,提问作者윤지상
相关产品推荐
相关产品推荐

