FCM - Get Message Label

不羁的心 提交于 2019-12-07 04:59:08

问题


To send a message from FCM backend, we have this view :

I wanna to get the message label (libellé du message) from RemoteMessage. When I debug for the field, the content in the message is labeled as google.c.a.c_l, which I think is an internal field.


回答1:


First, I just wonder the same as your question. But after read the document here and played around with it, I found that:

  • You cannot get the message label on client device, because it is just a label for display on firebase console only.
  • To get title at client side, you have to use Advanced options which is auto collapse at the bottom. With Advanced options, you can also send a data payload to the client by key/value.
  • Then remoteMessage.getNotification().getBody() for notification's message body (from Message text/Texte du message), remoteMessage.getNotification().getTitle() for notitifcation's title (from Advanced options), remoteMessage.getData() for data payload (from Advanced options).



回答2:


Try to get it with remoteMessage.getNotification().getTitle(). However, check before if remoteMessage.getNotification() != null.

Hope this helps.



来源:https://stackoverflow.com/questions/39368248/fcm-get-message-label

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!