Push notification from custom server
This can be done using 2 methods
with HTTP Post request, With Firebase admin SDK running on your server. Here I will discuss both of them.
Firebase Cloud Messaging HTTP Protocol
From your server request to the the link below to send the notification with some request parameters
While requesting add headers as follows
The body of the request varies
The to parameters takes Array of tokens like
or a single token like
or a topic name starting with /topic/ like
For multiple topic use conditions using || and && operators like
Using Admin SDK(Node js)
At first initilize the firebase sdk and admin SDK
Create a payload JSON string as in the first example.
Then call different send methods to send the notification.
This modified text is an extract of the original Stack Overflow Documentation created by following contributors
and released under CC BY-SA 3.0