无法在有效负载FCM的主体请求中传递aps参数?

时间:2017-10-07 14:22:31

标签: java android google-cloud-messaging cordova-plugin-fcm

click here to check postman request

在将GCM迁移到FCM时,我在GCM请求正文的请求正文中使用了aps参数,但在为FCM尝试相同时,它显示了InvalidParameters。

网址:https://fcm.googleapis.com/fcm/send

请求:

{
 "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"
}

响应:

{
    "multicast_id": 6282546760147817634,
    "success": 0,
    "failure": 1,
    "canonical_ids": 0,
    "results": [
        {
            "error": "InvalidParameters"
        }
    ]
}

2 个答案:

答案 0 :(得分:0)

出于某种原因,在将aps对象与data对象组合时,不允许使用notification参数。

如果删除notification对象,邮件将成功发送,但您将发送data push message而不是通知推送消息。

答案 1 :(得分:0)

//简单易用,您已经收到推送请求并且可以使用其他参数

"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"
}