如何使用C#中的Pushwoosh Web API向某些特定用户发送“推送通知"?

问题描述:

我想使用Pushwoosh Web API将Push通知广播给某些订阅者.

I want to broadcast the Push notification to some of the subscribers using the Pushwoosh Web API.

我一直在使用其网站此处

但是它正在发送给所有注册用户.如何仅将通知发送给某些特定用户?

But it is sending to all the registered users. How can I send the notification to some specific users only?

这是JSON制作代码:

Here is the JSON making code:

string pwAuth = "YOUR_AUTH_TOKEN";
       string pwApplication = "PW_APPLICATION_CODE";
       JObject json = new JObject(
           new JProperty("application", pwApplication),
           new JProperty("auth", pwAuth),
           new JProperty("notifications",
               new JArray(
                   new JObject(
                       new JProperty("send_date", "now"),
                       new JProperty("content", "test"),
                       new JProperty("wp_type", "Toast"),
                       new JProperty("wp_count", 3),
                       new JProperty("data",
                           new JObject(
                               new JProperty("custom", "json data"))),
                       new JProperty("link", "http://pushwoosh.com/"),
                       new JProperty("conditions",
                           new JArray(
                               (object)new JArray("Color", "EQ", "black")))))));
       PWCall("createMessage", json);

谢谢

您需要在JSON中添加属性"devices"以及您打算发送通知的不同设备的设备令牌.

You need to add the property "devices" in the JSON with the device tokens of the different devices you intend to send the notification.

赞:

 string[] arr = new string[1];
 arr[0] = "9d48ac049ca6f294ea25ae25f3472b0e7e160ba06729397f9985785477560b3a";

 JObject json = new JObject(
           new JProperty("application", pwApplication),
           new JProperty("auth", pwAuth),
           new JProperty("notifications",
               new JArray(
                   new JObject(
                       new JProperty("send_date", "now"),
                       new JProperty("content", new JObject(new JProperty("en", pushContentEnglish), new JProperty("es", pushContentSpanish))),               
                       new JProperty("data", new JObject(new JProperty("custom", new JObject(new JProperty("t", notificationType), new JProperty("i", objectId))))),
                       new JProperty("devices", new JArray(arr))
                       ))));

在这里,我已将"devices"属性设置为我打算向其发送通知的设备令牌的字符串数组.

Here I have set the "devices" property to the string array of device tokens to which I intent to send the notification.

PS-请小心输入给Devices属性的数组,因为一旦我将其值设置为逗号分隔的字符串而不是数组,Pushwoosh便将此通知广播给所有用户,而不是抛出错误!

PS - Be careful about the array you feed to the Devices property, because once I set its value to a comma separated string instead of array, and Pushwoosh broadcast-ed this notification to all users instead of throwing error!