0

I have a fleet of devices running python and need to be able to send messages to/from them each individually. I know that it is possible to send a message to an individual InstanceID token, but I can't figure out how to register a device to get an InstanceID token and then listen for messages.

I was hoping to have something like https://cloud.google.com/python/docs/reference/pubsub/latest/index.html#subscribing, where it would listen for messages for just that client. What I want is

client = messaging.client()
while true:
    msg = client.getMessage()
    print(msg)

I'm open to doing it with the REST API too, but can't find a way to do it there either. I've look at the python docs and the API docs.

I'm open to other ideas to accomplish this, like pub/sub, but that doesn't seem to support the individual device mapping. I could have a topic per device, but there's an upper limit of topics that may be too low.

Daniel Watrous
  • 3,467
  • 2
  • 36
  • 48

1 Answers1

1

While sending messages through Firebase Cloud Messaging is possible from most platforms, listening for messages from Firebase Cloud Messaging is only supported through the official SDKs that are available for Android, iOS and client-side JavaScript. There are no SDKs, or documented API for receiving messages on other platforms.

Given that you tagged with google-cloud-pubsub that (while unrelated to FCM) would probably be a good protocol/API to consider for delivering messages to Python clients. Within the Firebase suite of products, something like Realtime Database or Cloud Firestore would be other options - as both also support realtime listeners.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807