Android接入Firebase推送不执行onMessageReceived方法

参考:https://firebase.google.com/docs/cloud-messaging/android/receive
参考:https://firebase.google.com/docs/cloud-messaging/http-server-ref

Android接入Firebase推送,当应用处于后台状态时不执行FirebaseMessagingService的onMessageReceived方法

FCM处理后台应用中消息的机制:

当您的应用位于后台时,Android 会将通知消息转发至系统托盘。默认情况下,用户点击通知时将打开应用启动组件。

这会包括同时包含通知和数据负载的消息。在这些情况下,通知将传递至设备的系统托盘,数据负载将在应用启动组件 Activity 的 Intent 的 extra 中传递。

如果希望打开您的应用和执行特定操作,请在通知负载中设置 click_action,然后将其映射至您想启动的 Activity 中的 Intent 过滤器。例如,将 click_action 设为 FCM_OPEN_ORDER_LIST_ACTIVITY 会触发类似于如下的 Intent 过滤器:

<intent-filter>
  <action android:name="FCM_OPEN_ORDER_LIST_ACTIVITY" />
  <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

服务端推送notification参数配置click_action字段

var payload = {
  //to: token,
  to: '/topics/activity',
  notification: {
    body: "通知内容",
    title: "Firebase Cloud Message",
    data: {'type': 'test', 'path': '/order_list'},
    click_action: 'FCM_OPEN_ORDER_LIST_ACTIVITY'
  },
  data: {'type': 'test', 'path': '/order_list', 'content': 'AppBlog.CN'}
}
上一篇 Android接入Firebase推送通知
下一篇 Android使用AOP做登录拦截
目录
文章列表
1 Retrofit2学习之一:HelloWorld
Retrofit2学习之一:HelloWorld
2
Node.js 测试
Node.js 测试
3
RecyclerView操作数据及添加分割线
RecyclerView操作数据及添加分割线
4
C语言实现浮点型数据与字节数组的相互转化
C语言实现浮点型数据与字节数组的相互转化
5
Android 拨打电话(跳转拨打及直接拨通)
Android 拨打电话(跳转拨打及直接拨通)
最新评论
一位WordPress评论者
一位WordPress评论者
2月12日
您好,这是一条评论。若需要审核、编辑或删除评论,请访问仪表盘的评论界面。评论者头像来自 Gravatar。