Unofficial .NET Client Library for the PushBots v1 API
Install the NuGet package from the package manager console:
Install-Package PushBots.NET
Create an instance of PushBotsClient by passing in your Application ID and Secret (get this from your App settings page on the PushBots dashboard)
var client = new PushBotsClient("55165801f85f8b457d", "b03052506824b4f3165ecc0");
Push a notification to a single device
var pushMessageSingle = new SinglePush()
{
Message = "Test from API",
Token =
"APA91bGE09bhztuOZyFxI2txOOAXrELuVQ38WWC-yrX6MpgNgjylVdXLygkbGbIU9x6aToJl3C5nVGJtdteAyGVbY19TSBWYnYip0-Arjv3-6KRDq9sDobbpc17yxb3OpFO_nxxxxxxxxxxx",
Platform = Platform.Android,
Badge = "+1",
Sound = "",
Payload = JObject.Parse(@"{ 'openURL': 'http://www.google.com/' }")
};
await client.Push(pushMessageSingle);
Push a notification to Devices under certain conditions
var pushMessage = new BatchPush()
{
Message = "Test from API",
Badge = "+1",
Platforms = new[] { Platform.Android, Platform.iOS }
};
var result = await client.Push(pushMessage);
var result =
await
client.Badge(
"APA91x9bhzxxZC88kxxAXrELuVQ38WWC-yrX6MpgNgjylVdXLygkbGbIU9x6aToJl3C5nVGJtdteAyGVbY19TSBWYnYip0-Arjv3-6xxxxxx",
"0", 1);
return result;
NOTE: Currently only supports iOS platform, if you pass through a "1" for Android it will return an error
Get Push Analytics for a single application
var result = await client.GetPushAnalytics();
return result;
Utility function to retrieve all devices registered with PushBots along with their device token
var devices = client.GetDevices();
Get device information by it's registered Alias
var device = await client.GetDeviceByAlias("TestUser");
var device = new Device
{
Token = "xxxxxxxxxxx",
Platform = Platform.Android,
Latitude = "33.7489", // Optional
Longitude = "-84.3789", // Optional
Types = new[] {"Subscriptions", "Followers"}, // Optional
Tags = new[] {"Culture", "Egypt"}, // Optional
Alias = "test@example.com"
};
var response = await client.RegisterDevice(device);
Register multiple devices up to 500 Device per request
var response = await client.RegisterDevice(
new [] {"xxxxx"}, // Array of Tokens
Platform.Android,
new[] { "Culture", "USA" } // Optional array of Tags
);
unRegister device token of the app from the database
Tag a device with its token through SDK or Alias through your backend
unTag a device its token through SDK or Alias through your backend