Firebase Cloud Messaging: how to send data message to all users? [duplicate]

倾然丶 夕夏残阳落幕 提交于 2019-12-22 18:22:23

问题


I would like to send data messages to all users.

Is it possible to do it programmatically, without using the Firebase Notifications Console?

The problem with the Console is that the "message text" field at the beginning of the form is compulsory. So, even if I add the custom data key/values, there will also be the standard notification component.

As stated here, when the message includes both notification and data, in case the app is in the background, a standard notification message will be notified to the system tray.

I would like instead to deliver only a notification based on the custom data (trigged by OnMessageReceived).

How can I achieve that? Programmatically, I can correctly send data messages to specific users, but I cannot find a way to send data messages to ALL users.


回答1:


Use topic messaging. You can define the name of a topic that all installations of your app will subscribe to, then send the message to that topic.

You can use the Firebase Admin SDK from your server to send that message. Or you can use the FCM HTTP API to send that message.



来源:https://stackoverflow.com/questions/49013491/firebase-cloud-messaging-how-to-send-data-message-to-all-users

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