google-cloud-messaging Getting started with google-cloud-messaging Send downstream messages from the cloud

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

Send a message using GCM HTTP connection server protocol:

  https://gcm-http.googleapis.com/gcm/send
  Content-Type:application/json
  Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA
  {
    "to": "/topics/foo-bar",
    "data": {
      "message": "This is a GCM Topic Message!",
     }
  }

To do this in Postman, you simply have to set the following (some details are as what is mentioned above):

  1. Set request type to POST
  2. In the Headers, set the following:
    • Content-Type = application/json
    • Authorization = < Your GCM Server Key >
  3. Set the payload parameters in the Body (in this example, we used the raw option, see screenshot (2))
  4. Send the request to https://gcm-http.googleapis.com/gcm/send

Screenshots:

(1) enter image description here

(2) enter image description here

Notice that the request was a success with the message_id in the response.

PS: I'm keeping the sample Server Key visible so that others can still try it out even if they haven't created a Project yet. BUT, note that the Server Key must be always kept secret.



Got any google-cloud-messaging Question?