How to send a simple Firebase push notification to

2019-09-19 15:58发布

问题:

I've been doing so much research, but it seems like all the articles out there are either sending notifications from the console or sending a push notification to a single device.

All I want is to send a push notification using Firebase ON my client and not on the Console to everyone. Do I need a server? If so, what information do I need to retrieve from it?

回答1:

If you simply want to send a downstream message, you don't really need a server. You can simply use Postman or cURL. Just specify the registration token(s)/topic you want to send your message payload to.

If you are aiming to send the downstream message from the client (Android app) itself, I would strongly advise not to. Quoting a portion of @FrankvanPuffelen's answer here:

Sending a message to devices (so-called downstream messages) requires a HTTP call that specifies the server key. As its name implies, this key should only be used in environments you can trust.

It is to avoid exposing the key to unauthorized users, preventing exploitation.