Firebase 消息推送遇到的坑

Firebase消息推送分为前台和后台:

1,当应用处于前台的时候,推送的消息会走onMessageReceived方法,我们可以根据参数RemoteMessage获取需要的参数,流程是没问题的;

2,当应用处于后台的时候,发现推送消息的时候不会走onMessageReceived方法,点击推送通知会走默认进入应用,获取不了我们需要的数据,无法特定跳转,后来发下官方文档说明;

Handle messages in a backgrounded app
When your app is in the background, Android directs notification messages to the system tray. A user tap on the notification opens the app launcher by default.

This includes messages that contain both notification and data payload. In these cases, the notification is delivered to the device's system tray, and the data payload is delivered in the extras of the intent of your launcher Activity.

翻译之后为:处理后台应用程序中的消息当应用程序位于后台时,Android会将通知消息定向到系统托盘。默认情况下,用户点击通知将打开应用程序启动程序。这包括包含通知和数据负载的消息。在这些情况下,通知将传递到设备的系统托盘,数据有效负载将在启动程序活动意图的附加部分中传递。

通俗点就是,当应用处于后台,推送消息的数据会走启动页,通过getIntent().getExtra()获取所有需要的参数数据;

 

 

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值