Class
JPushClient
This class is the core for calling JPush API via official RESTful interfaces.
There are two major features:
Sample:
Here is a sample based on .NET console application.
class Program { static void Main(string[] args) { var appKey = "1234567890abcdef"; // Your App Key from JPush var masterSecret = "1234567890abcdef"; // Your Master Secret from JPush Dictionary<string, string> customizedValues = new Dictionary<string, string>(); customizedValues.Add("CK1", "CV1"); customizedValues.Add("CK2", "CV2"); JPushClient client = new JPushClient(appKey, masterSecret, false); var response = client.SendPushMessage(new PushMessageRequest { MessageType = MessageType.Notification, Platform = PushPlatform.Android, Description = "DotNET", PushType = PushType.Broadcast, IsTestEnvironment = true, Message = new PushMessage { Content = "Hello, this is a test push from .NET. Have a nice day!", PushTitle = "A title.", Sound = "YourSound", CustomizedValue = customizedValues } }); Console.WriteLine(response.ResponseCode.ToString() + ":" + response.ResponseMessage); Console.WriteLine("Push sent."); Console.WriteLine(response.ResponseCode.ToString() + ":" + response.ResponseMessage); List<string> idToCheck = new List<string>(); idToCheck.Add(response.MessageId); var statusList = client.QueryPushMessageStatus(idToCheck); Console.WriteLine("Status track is completed."); if (statusList != null) { foreach (var one in statusList) { Console.WriteLine(string.Format("Id: {0}, Android: {1}, iOS: {2}", one.MessageId, one.AndroidDeliveredCount, one.ApplePushNotificationDeliveredCount)); } } Console.WriteLine("Press any key to exit."); Console.Read(); } } |
RESTful API reference: http://docs.jpush.cn/display/dev/Index
NOTE: