使用自定义 GCM 参数将通知推送到 android 设备

Push Notification to android device with custom GCM parameters

我正在使用 JavaScript SDK - v2.1.2 :

我的查询:如何使用 JavaScript 在 android 设备中发送带有自定义 gcm 参数的推送通知。

我正在尝试使用我的 JavaScript 代码向 android 设备发送推送通知,但在我们的应用程序中,我们使用名为 CleverTap 的第三方接收器通知。 以下是 CleverTap 接收器的强制参数: "wzrk_pn" "wzrk_sound" "nt" "nm" "wzrk_dl" 我需要将其作为自定义参数发送。

以下是我的推送通知代码:

var pushCustomParams = {
    message: 'Message received from Bob',
    wzrk_pn: 1,
    wzrk_sound: 1,
    nt: 'Revofit',
    nm: 'This msg is from application',
    wzrk_dl: ''
}
var params = {
    notification_type : 'push',
    push_type : 'gcm', // 'gcm' is for Android, 'apns' - for iOS.
    user : { ids: [14411551] }, // recipients.
    environment : 'development', // environment, can be 'production' as well.
    message :   QB.pushnotifications.base64Encode(JSON.stringify(pushCustomParams)), // See how to form iOS or Android spesific push notifications
};

 QB.pushnotifications.events.create(params, function(err, response) {
    if (err) {
        console.log(err);
    } else {
        // success
        console.log(response);
    }
  });

执行上述代码后产生的日志如下:

 {
    "notification": {
        "registration_ids": ["dFCRdN7MJD0:APA91bFsaOdorqhvRyMuUGH-Ds8Z_EB6pQWHpQIYy5YVUefwYFwqK39E5BsLtJ2cHYDLv9mPXDQc4mAQRhJTdM2unUgy6-kmWSWMorp0ZSbBL1EdjFZLiorh4LQT3JR454dqEP1bL2_l"],
        "delay_while_idle": false,
        "data": {
             "message": "{\"message\":\"Message received from Bob\",\"wzrk_pn\":1,\"wzrk_sound\":1,\"nt\":\"Revofit\",\"nm\":\"This msg is from application\"}",
             "collapse_key": "event7637817"
    },
          "priority": "high",
         "time_to_live": 86400
     },
     "log": [{
        "device_token": null,
        "created_at": "2016-06-30T14:26:46Z",
        "delivered_at": "2016-06-30T14:26:47Z",
        "failed_at": null,
        "error_code": null,
       "error_description": null
     }]
    }

但是当我尝试使用我自定义的 GCM 参数通道设置从管理面板发送推送通知时,它工作正常。 为来自管理面板的通知生成的日志:

 {
     "notification": {
        "registration_ids":     ["eShiPWpBngA:APA91bFzFeaB0LryAt9FmEJ9xl2KHWhZWlfzpYhng4KONN60yr3ySl2R58Eye-qSmhzQ56T2Fyuzr0Yg4y1VWMIm20LH74U7BWO_Az7MgogBD2IGvmWEKvJWWgVH6sD-3wP_gaIgJEAY"],
        "delay_while_idle": false,
         "data": {
            "message": "hii",
            "wzrk_pn": "1",
            "nm": "New message",
            "nt": "revofit",
            "collapse_key": "event7632938"
         },
        "priority": "high",
        "time_to_live": 86400
     },
    "log": [{
        "device_token": null,
        "created_at": "2016-06-30T08:17:25Z",
         "delivered_at": "2016-06-30T08:17:26Z",
        "failed_at": null,
        "error_code": null,
        "error_description": null
    }]
 }

我无法纠正我的错误 请帮我解决这个问题。

抱歉我的英语不好。我尽力了。

由于我们无法获得所需的解决方案,我们更换了 GCM 接收器。