google Cloud Messaging Push notification

后端 未结 3 2028
时光说笑
时光说笑 2020-12-31 05:23

Can I use POSTMAN client on Google Chrome to send payload message to GCM server for testing purpose. Secondly if yes, what is the header and url parameter to be sent.

3条回答
  •  我在风中等你
    2020-12-31 05:34

    Yes, you can.

    1. Send a notification with a JSON payload

    URL: https://android.googleapis.com/gcm/send

    Headers:

    • Authorization: key=
    • Content-Type: application/json

    Body (click on the 'raw' tab):

    {
      "collapse_key": "score_update",
      "time_to_live": 108,
      "delay_while_idle": true,
      "data": {
        "score": "4x8",
        "time": "15:16.2342"
      },
      "registration_ids":["4", "8", "15", "16", "23", "42"]
    }
    

    Note: registration_ids is the only required field, all the others are optional.

    2. Send a notification with a plain text payload

    URL: https://android.googleapis.com/gcm/send

    Headers:

    • Authorization: key=
    • Content-Type: application/x-www-form-urlencoded;charset=UTF-8

    Body (click on the 'x-www-form-urlencoded' tab):

    collapse_key=score_update
    time_to_live=108
    delay_while_idle=1
    data.score=4x8
    data.time=15:16.2342
    registration_id=42
    

    Note: registration_id is the only required field, all the others are optional.


    Source: https://developer.android.com/google/gcm/http.html

提交回复
热议问题