Bawpotter Bawpotter - 1 year ago 484
HTTP Question

Firebase Notifications: Send Message Through HTTP Post

I have Firebase Notifications set up in my app right now, and when I send a message the message is sent to all users of my app. (I currently send messages through the Firebase console). I'd like another way of sending push notifications that doesn't involve the Firebase console, and I believe that HTTP Post is an easy way of doing this. How do I go about sending a push notification remotely with HTTP Post?

Answer Source

Edited because on comment: Please make sure do NOT include the server-key into your client. There are ways "for not so great people" to find it and do stuff... The Proper way to achieve that is for youre client to instruct youre app-server to send the notification.

You have to send a HTTP-Post to the Google-API-Endpoint.

You need the following headers:

Content-Type: application/json
Authorization: key={your_server_key}

You can obtain youre server key within in the Firebase-Project.

HTTP-Post-Content: Sample

    "notification": {
        "title": "Notification Title",
        "text": "The Text of the notification."
    "project_id": "<your firebase-project-id",
    "to":"the specific client-device-id"

Example Device ID:


You have to send this request to As of now it is not possible to send a notification to all devices using the API. You have to use the Firebase-Console for that.

I like to use the Chrome-Plugin "Postman" for sending API requests, as you can save your HTTP-Requests. Its very comfortable.

You can use curl as well.

-d "{ "notification": {
    "title": "Notification Title",
    "text": "The Text of the notification."
  "project_id": "<your firebase-project-id",
  "to":"the specific client-device-id"
-H "Content-Type: application/json" 
-H "Authorization: key={your_server_key}"