Firebase, send message to specific platform (Android)

偶尔善良 提交于 2019-12-06 11:56:18

With Firebase Cloud Messaging, you have a few ways to address to whom messages are sent:

  1. to a specific device
  2. to a device group
  3. to a topic

The Firebase Notifications tab in the new Firebase Console uses either #1 or #2 to send to groups of users.

But it looks like what you are looking for can be most easily accomplished by sending to a topic:

FirebaseMessaging messaging = FirebaseMessaging.getInstance()
messaging.subscribeToTopic("package_kz_mycompany_myapp");

Then your server-code can push messages to this topic to have it reach all devices that have subscribed to the topic:

var topic = '/topics/package_kz_mycompany_myapp';
var data = { "data": {
               "score": "5x1",
               "time": "15:10"
           },
           to : topic };
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!