如何在MFP的推送通知中发送促销图片

时间:2018-07-13 09:36:16

标签: push-notification apple-push-notifications ibm-mobilefirst worklight-server worklight-runtime

如何像下面的图像一样在推送通知中发送促销图像?我需要在有效载荷中使用任何html代码吗?如有可能,请共享代码段。

like this

2 个答案:

答案 0 :(得分:0)

编辑2019年4月:

IBM MobileFirst 8.0支持发送丰富的推送通知。更新到最新的服务器和客户端修订包以获取功能。调度Push时,请使用以下有效负载结构:

推送有效载荷:

{  
   "message":{  
      "alert":"Picture Notification for Android devices ",
      "url":"http://www.test.com"
   },
   "target":{  
      "deviceIds": ["MyDeviceId1", ...],
      "platforms": ["A,G", ...],
      "tagNames": ["Gold", ...],
      "userIds": ["MyUserId", ...]
   },
   "settings":{  
      "gcm":{  
         "style":{  
            "notification_type":"PICTURE_NOTIFICATION",
            "url":"<URL of the image that needs to be displayed>",
            "title":"Test"
         },
      "apns": {
         "attachmentUrl" : "http://test.com/test.png",
         "badge" : 1,
         "category" : 1,
         "iosActionKey" : "Ok",
         "launchImage" : "test.png",
         "locArgs" : [ "["Shelly"]", ... ],
         "locKey" : "REQ_FORMAT",
         "payload" : {"custom":"data"},
         "sound" : "song.mp3",
         "subtitle" : "Sub Title",
         "title" : "Title",
         "titleLocArgs" : [ "["Shelly"]", ... ],
         "titleLocKey" : "REQ_FORMAT",
         "type" : "SILENT"
        }
      }
   }
}

答案 1 :(得分:0)

我收到错误消息“错误的请求-JSON验证在'gcm'处失败。”具有以下JSON负载:-

{
  "settings": {
    "gcm": {
        "payload": {
          "action": "ACTION",
          "path": "/path"
        },
        "style":{  
            "notification_type":"PICTURE_NOTIFICATION",
            "url":"https://homepages.cae.wisc.edu/~ece533/images/airplane.png",
            "title":"RICH PUSH"
         }
    },
    "apns": {
      "payload": {
          "action": "ACTION",
          "path": "/path"
        }
    }
  },
  "message": {
    "alert": "Test MFP PUSH Notification."
  },
  "target": {
    "userIds" : ["11359164"]
  }
}

响应JSON:-

{
    "code": "FPWSE0011E",`enter code here`
    "message": "Bad Request - The JSON validation failed at 'gcm'."
}

我正在使用MFP 8.0,请在上述JSON中建议更改。