点击FCM通知消息时如何获取消息正文? [英] how get message body when FCM notification message is tap?
问题描述
当应用程序在后台运行时,通知消息是通过通知传递的,当点击通知时,启动应用程序时,如何获取消息正文?
When app is in background, the notification message is deliver by Notification, when the notification is tap, app is launch, how can i get the message body?
目的是:
Bundle[{google.sent_time=1470813025421, from=568540028909,
google.message_id=0:1470813025865549%31bd1c9631bd1c96,
collapse_key=com.google.firebase.quickstart.fcm}]
没有意图的消息正文,只有消息ID! 谢谢!
no message body in intent, only message id! Thanks!
推荐答案
很抱歉,但是您尝试执行的操作是不可能的.
I am sorry but what you are trying to do is not possible.
当前无法访问a
的(正文,标题,图标...)信息
notification-message
来自打开通知时启动的活动.
Currently it's not possible to access the (body, title, icon ...) information of a
notification-message
from the activity that is launched when the notification is opened.
您可以改为访问通知消息的数据部分.
You can instead access the data component of the notification message.
一种可能的选择是使用data-message
消息并创建自己的自定义通知和自定义逻辑.
One possible alternative is to use data-message
messages and create your own custom notification and custom logic.
在此处参见notification-message
与data-message
:
https://firebase.google.com/docs/cloud-messaging/concept -options#notifications_and_data_messages
see notification-message
vs data-message
here:
https://firebase.google.com/docs/cloud-messaging/concept-options#notifications_and_data_messages
PS:如果您可以通过firebase支持页面报告功能请求,这将很有用.
这样,团队可以正确地确定未来功能的优先级.
https://firebase.google.com/support/contact/bugs-features/
PS: if would be useful if you could report a Feature Request through the firebase support page.
In this way the team can correctly prioritize future features.
https://firebase.google.com/support/contact/bugs-features/
这篇关于点击FCM通知消息时如何获取消息正文?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!