【问题标题】:Can't pass aps parameter in body request of payload FCM?无法在有效载荷 FCM 的正文请求中传递 aps 参数?
【发布时间】:2017-10-07 14:22:31
【问题描述】:

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

【问题讨论】:

  • 你不能发送 aps,因为限制是每个值都必须是一个字符串,aps 是一个对象现在找不到文档

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


【解决方案1】:

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

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

【讨论】:

    【解决方案2】:

    //简单这个很容易使用,你已经收到推送,可以使用额外的参数

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-15
      • 2023-01-05
      • 2021-05-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多