Search code examples
firebasefirebase-cloud-messagingfirebase-notifications

Is it possible to create Firebase Cloud Messaging topics without a device token?(web-app)


The point of this is to create 100 topics from a list. When this is done my application will go through this list once every day to check for upcoming events. A message will be sent to the subscribed users if the app finds an event on a particular topic. I will also try to implement some logic to check if there are users subscribed to this particular topic.


Solution

  • Two parts to your question:

    Firebase topic subscription is officially documented only for devices. In other words, only devices with device tokens can subscribe to a topic. Look at AWS SNS topics for topics on which other applications can subscribe.

    Secondly, for your use case, topics may not be the solution. Generally, a topic is not like a queue from which you can retrieve a message. Generally, a topic will only send messages to subscribers already actively subscribed to the topic. If there is no subscriber on the topic when a message is received, the message disappears.