java - 无法在 payload FCM 的 body 请求中传递 aps 参数?

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

最佳答案

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

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

关于java - 无法在 payload FCM 的 body 请求中传递 aps 参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46621248/

相关文章:

java - 在字符串集合中使用通配符搜索

java - 虽然 hasNext() 不会结束

java - 在 JEditorPane 中高亮一个词

android - 为什么在 startActivityForResult 之后调用 oncreate 方法?

java - 无法从数据库读取值

android - 从 View 创建位图使 View 消失,如何获取 View Canvas ?

android - GCM 云连接服务器中上游消息传递的主要用途是什么?

java - java - 如何创建公平锁来解决java中的饥饿问题?

android - Google Cloud Messaging 设备未收到通知。 (没有 "Registered Apps"链接)

android - 向移动设备推送通知 : SNS vs OneSignal vs GCM