2

click here to check postman request

While migrating GCM to FCM I was using aps parameter in request body of GCM request body but when trying same for FCM its showing InvalidParameters.

Url: https://fcm.googleapis.com/fcm/send

Request:

{
 "notification": {
  "title": "notification title",
  "body": "message body changed  11"
 },
 "data": {
  "mt": "re",
  "offerid": "10562",
  "aps":{"badge":0,"alert":"gauravtest,$20 OFF COUPON","sound":"null.caf"},
  "clpnid": "xxx",
  "custid": "xxx",
  "eoid": "0",
  "pc": "171-2802-8180",
  "ed": "11/08/2017",
  "ag": "",
  "url": "",
  "previewimage": ""


 },
 "to": "xxxx"
}

Response:

{
    "multicast_id": 6282546760147817634,
    "success": 0,
    "failure": 1,
    "canonical_ids": 0,
    "results": [
        {
            "error": "InvalidParameters"
        }
    ]
}
  • You cant send aps because the restriction is every value has to be a String, aps is an object Cant find the doc now – cutiko Jan 12 '19 at 21:45

2 Answers2

0

For some reason, the aps paramater isn't allowed while combining the data object with a notification object.

If you remove the notification object the message will be sent successfully, but you'll be sending a data push message instead of a notification push message.

fifarunnerr
  • 617
  • 4
  • 12
0

//Simple its very easy use this and you have receive push and can use the extra parameters

"notification": {
  "title": "notification title",
  "body": "message body changed  11"
  "content_available": true,
  "extraParameter_1": "any kind of data ",
  "extraParameter_2": "any kind of data 2"
}
Shakeel Ahmed
  • 5,361
  • 1
  • 43
  • 34