0

Is there a way to send a message to an entire application instead of a list of devices / topic outside the Firebase console?

Inside the console you can accomplish this like so:

enter image description here

But if I'm using their API, I can't find a way to send the message to the app.

I have found a workaround (subscribing every app to the same topic) that works perfectly, but I would prefer the app option.

Grender
  • 1,589
  • 2
  • 17
  • 44
  • You can send with notification with their API using an http Client app like Postman, Also What do you mean by " but I would prefer the app option" ? – Tosin Onikute Oct 22 '16 at 19:21
  • I have a PHP server working perfectly, that's not the problem. My problem is that I can't find a way to send the message to the entire app using their API as in the Firebase Console. – Grender Oct 22 '16 at 19:25
  • 1
    Once you subscribe users of your app to a topic, every user gets the message sent to that topic. You can't send message to the entire users of your app with API without a topic. It only works in Firebase Console. See this explanation: http://stackoverflow.com/questions/37634563/fcm-firebase-cloud-messaging-how-to-send-to-all-phones – Tosin Onikute Oct 22 '16 at 19:30
  • @HtmlTosin Thanks a lot, if you submit an answer I can mark this question as solved :) – Grender Oct 22 '16 at 19:47
  • Submit an answer? You mean how subscribe to a topic? I think you already have an answer from that link. – Tosin Onikute Oct 22 '16 at 20:02
  • 1
    I mean that YOU can answer this question instead of writing the solution as a comment, so I can mark this as solved, lol. – Grender Oct 22 '16 at 20:08

1 Answers1

1

Once you subscribe users of your app to a topic, every user gets the message sent to that topic.

You can't send message to the entire users of your app with API without a topic. It only works in Firebase Console. See this explanation: FCM (Firebase Cloud Messaging) how to send to all Phones?

Community
  • 1
  • 1
Tosin Onikute
  • 3,883
  • 6
  • 38
  • 61
  • Where should I place the `FirebaseMessaging.getInstance().subscribeToTopic("topic_name");` ? In the `onTokenRefresh()` method from the `FirebaseInstanceIdService` or in the `onCreate()` method from the main activity? – Grender Oct 22 '16 at 20:20
  • onCreate() method from the main activity – Tosin Onikute Oct 22 '16 at 20:23
  • So a good approach would be subscribing the client to the topic only on first application boot, wouldn't be? I can control it with `SharedPreferences`. – Grender Oct 22 '16 at 20:26