Skip to content

Instantly share code, notes, and snippets.

@DalSoft
Last active August 29, 2015 14:21
Show Gist options
  • Save DalSoft/f3413caae03c36ae3112 to your computer and use it in GitHub Desktop.
Save DalSoft/f3413caae03c36ae3112 to your computer and use it in GitHub Desktop.
DalSoft.RestClient - dynamic C# rest client in action PushWoosh SDK
// Method /createMessage https://www.pushwoosh.com/programming-push-notification/pushwoosh-push-notification-remote-api/#PushserviceAPI-Method-messages-create
dynamic pushwoosh = new RestClient("https://cp.pushwoosh.com/json/1.3");
var pushWooshResponse = await pushwoosh.CreateMessage.Post(new
{
request = new
{
application = "APPLICATION_CODE",
auth = "API_ACCESS_TOKEN",
notifications = new[] { new {
send_date = "now", // YYYY-MM-DD HH:mm OR 'now'
ignore_user_timezone = true, // or false
content = "your message",
// Optional. Not more than 1000 tokens in an array. If set, message will only be delivered to the devices in the list. Ignored if the applications group is used. Only lower case for iOS
devices = new[] { "dec301908b9ba8df85e57a58e40f96f523f4c2068674f5fe2ba25cdc250a2a41" } //
}}
}
});
// Method /deleteMessage https://www.pushwoosh.com/programming-push-notification/pushwoosh-push-notification-remote-api/#PushserviceAPI-Method-messages-delete
dynamic pushwoosh = new RestClient("https://cp.pushwoosh.com/json/1.3");
var response = await pushwoosh.DeleteMessage.Post(new
{
request = new
{
auth = "api_access_token",
message = "Message code obtained in createMessage"
}
});
// Method /getNearestZone https://www.pushwoosh.com/programming-push-notification/pushwoosh-push-notification-remote-api/#PushserviceAPI-MethodGetNearestZone
dynamic pushwoosh = new RestClient("https://cp.pushwoosh.com/json/1.3");
var response = await pushwoosh.GetNearestZone.Post(new
{
request = new
{
application = "APPLICATION_CODE",
hwid = "hardware device id",
lat = 10.12345,
lng = 28.12345
}
});
// Method /getTags https://www.pushwoosh.com/programming-push-notification/pushwoosh-push-notification-remote-api/#PushserviceAPI-MethodGetTags
dynamic pushwoosh = new RestClient("https://cp.pushwoosh.com/json/1.3");
var response = await pushwoosh.GetTags.Post(new
{
request = new
{
auth = "api_access_token",
application = "APPLICATION_CODE",
hwid = "hardware device id"
}
});
// Method /pushStat https://www.pushwoosh.com/programming-push-notification/pushwoosh-push-notification-remote-api/#PushserviceAPI-MethodPushStat
dynamic pushwoosh = new RestClient("https://cp.pushwoosh.com/json/1.3");
var response = await pushwoosh.PushStat.Post(new
{
request = new
{
application = "APPLICATION_CODE",
hwid = "hardware device id",
hash = "hash" // received in the push notification in the "p" parameter
}
});
// Method /registerDevice https://www.pushwoosh.com/programming-push-notification/pushwoosh-push-notification-remote-api/#PushserviceAPI-MethodRegister
dynamic pushwoosh = new RestClient("https://cp.pushwoosh.com/json/1.3");
var response = await pushwoosh.RegisterDevice.Post(new
{
request = new
{
application = "APPLICATION_CODE",
push_token = "DEVICE_PUSH_TOKEN",
hwid = "hardware device id",
device_type = 1
}
});
// Method /setBadge https://www.pushwoosh.com/programming-push-notification/pushwoosh-push-notification-remote-api/#PushserviceAPI-MethodSetBadge
dynamic pushwoosh = new RestClient("https://cp.pushwoosh.com/json/1.3");
var response = await pushwoosh.SetBadge.Post(new
{
request = new
{
application = "APPLICATION_CODE",
hwid = "hardware device id",
badge = 5
}
});
// Method /setTags https://www.pushwoosh.com/programming-push-notification/pushwoosh-push-notification-remote-api/#PushserviceAPI-MethodSetTags
dynamic pushwoosh = new RestClient("https://cp.pushwoosh.com/json/1.3");
var response = await pushwoosh.SetTags.Post(new
{
request = new
{
application = "APPLICATION_CODE",
hwid = "hardware device id",
tags = new {
StringTag = "string value",
IntegerTag = 42,
ListTag = new[] { "string1", "string2" }
}}
}
});
//Method /unregisterDevice https://www.pushwoosh.com/programming-push-notification/pushwoosh-push-notification-remote-api/#PushserviceAPI-MethodUnregister
dynamic pushwoosh = new RestClient("https://cp.pushwoosh.com/json/1.3");
var response = await pushwoosh.UnRegisterDevice.Post(new
{
request = new
{
application = "APPLICATION_CODE",
hwid = "hardware device id"
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment