gpt4 book ai didi

c# - 如何在 C# 中使用 Pushwoosh Web API 向某些特定用户发送推送通知?

转载 作者:太空狗 更新时间:2023-10-30 01:04:01 26 4
gpt4 key购买 nike

我想使用 Pushwoosh Web API 向一些订阅者广播推送通知。

我一直在使用他们网站上给出的代码here

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

JSON制作代码如下:

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”以及您打算发送通知的不同设备的设备 token 。

像这样:

 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”属性设置为我打算向其发送通知的设备 token 的字符串数组。

PS - 请注意您提供给 Devices 属性的数组,因为一旦我将其值设置为逗号分隔的字符串而不是数组,并且 Pushwoosh 向所有用户广播此通知而不是抛出错误!

关于c# - 如何在 C# 中使用 Pushwoosh Web API 向某些特定用户发送推送通知?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25155644/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com