Push notification FMC推送通知android后台

Push notification FMC推送通知android后台,push-notification,fmc,Push Notification,Fmc,我是推送通知方面的新手,我有一个问题,当应用程序收到通知且应用程序打开时,类“FCMinentService Extendes FirebaseMessagingService”正确执行,但当应用程序关闭或在后台时,不执行该类。为什么?哪个类处理通知?Firebase云消息传递有两个概念,一个是“通知”,另一个是“数据” 在前台,通知被正确地发送到onMessageReceived()方法,但在后台,通知被发送到系统托盘中,请参见图像 解决方案:使用数据字段从服务器发送通知 不要使用notif

我是推送通知方面的新手,我有一个问题,当应用程序收到通知且应用程序打开时,类“FCMinentService Extendes FirebaseMessagingService”正确执行,但当应用程序关闭或在后台时,不执行该类。为什么?哪个类处理通知?

Firebase云消息传递有两个概念,一个是“通知”,另一个是“数据”

在前台,通知被正确地发送到
onMessageReceived()
方法,但在后台,通知被发送到系统托盘中,请参见图像

解决方案:使用数据字段从服务器发送通知

不要使用notification对象从服务器发送通知

{
  "message":{
    "token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
    "notification":{   // Don't use the notification           
      "title":"Portugal vs. Denmark",
      "body":"great match!"
    }
  }
}
使用数据字段从服务器发送通知,它将在后台和前台工作

{
      "message":{
        "token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
        "data":{   // Use the data object to send the notification
          "title":"Portugal vs. Denmark",
          "body":"great match!"
        }
      }
    }