FCM (Firebase Cloud Messaging) how to send to all

2020-01-28 09:02发布

问题:

I have created a small App that's able to receive Push Notifications from the FCM Console.

What i want to do now is to send a Push-Notifications to all Android Phones that got the app Installed using the API. And this is where i got completely lost. Is there no way to send it to all Phones without collecting all the registration-ids? Does this only work with the Console but not with the API?

thanx in advance

回答1:

Sending a message to all the phones like what you do from the Firebase Web Console is only possible from the Web Console. If you need this feature from the API you can submit a feature request: https://firebase.google.com/support/contact/bugs-features/

Another possibility is to have all the client registering to a specific topic via FirebaseMessaging.getInstance().subscribeToTopic(topicName)

In this way you can send a message to the whole topic without collecting the registration-ids manually.