Gcm send and receive push payload data using web (chrome)

I am trying to send data to gcm and on the client side get it. all things are work, and push is receiving, but the submitted data is zero, try the postman as follows:

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

Headers:

Authorization: key=<your-api-key>
Content-Type: application/json

Body

{
  "collapse_key": "score_update",
  "time_to_live": 108,
  "delay_while_idle": true,
  "data": {
    "key1": "value1",
    "key2": "value2"
  },
  "registration_ids":["eaFbvFT64EQ:APA91bEfdq8QDTU2XbQ3V1bhC5UnMz2ZKWUQokq3Ta79Vg_2-Z8rnI6MFCxko6hVt3EoSQoqa24-ddjy8iSbxoP36rvXoGcPqsMQWFjzM5mz6K8tPbfoL2zEEfDxvcXajlb_-vw2vmpv"]
}

in this way, work and send push to the client with registration_oid data, but the data is submitted.

and try in a different way from to instead of register_id, for example:

{
     "to":"eaFbvFT64EQ:APA91bEfdq8QDTU2XbQ3V1bhC5UnMz2ZKWUQokq3Ta79Vg_2-Z8rnI6MFCxko6hVt3EoSQoqa24-ddjy8iSbxoP36rvXoGcPqsMQWFjzM5mz6K8tPbfoL2zEEfDxvcXajlb_-vw2vmpv",
     "data": {
    "key1": "value1",
    "key2": "value2"
  }
}

and, like the last method, push reception with zero data

I find the https://github.com/gauntface/simple-push-demo project and implement it. this project works very well, but in this project the payload data is encrypted as follows:

Headers:

Authorization: key=<your-api-key>
Content-Type: application/json
Encryption: salt=L_da9h_5eIPS1c0gNV3fOQ
Crypto-Key: dh=BPDpQTlRDuk8DBFB3LxuTSnevgZGla7g8-LrTRSvUkPiU_ZsQVppocib1lFTYKP33bENL_gaMahaEXinMuYwu-c

Body

{
    "to":"fE5h8Q6gtno:APA91bEO-_LLDOIGMStAxR9J58RwA5fOSdvwVKNYkBnq7Xohm5kf-b4Gc4iq6BzrwEIgZxsKb3EKCtAsQgS34sKWpVEzX_gWx7OpCUuzKRqg50zOt2TjMR1KjHYwV3EkiE0BUh6JS-qu",
    "raw_data":"NBpw3QkilspdNClRE1k1CYsg1wHT3Q=="

}

question:

1- gcm push-

2- to register_ids

+4

All Articles