public void TestSchemaIOSPushNotification() { string expected = ""+ "{"+ "\"device_tokens\": ["+ " \"some device token\","+ " \"another device token\""+ "],"+ "\"aliases\": ["+ " \"user1\","+ " \"user2\""+ "],"+ "\"tags\": ["+ " \"tag1\","+ " \"tag2\""+ "],"+ "\"schedule_for\": ["+ " \"2010-07-27 22:48:00\","+ " \"2010-07-28 22:48:00\""+ "],"+ "\"exclude_tokens\": ["+ " \"device token you want to skip\","+ " \"another device token you want to skip\""+ "],"+ "\"aps\": {"+ " \"badge\": \"10\","+ " \"sound\": \"cat.caf\""+ "}}"; var push = new IOSPushNotificationRequest() { Aliases = new List<string>() { "user1", "user2" }, APS = new IOSAPSBody() { Badge = "10", Sound = "cat.caf" }, ExcludeTokens = new List<string>() { "device token you want to skip", "another device token you want to skip" }, Tags = new List<string>() { "tag1", "tag2" }, DeviceTokens = new List<string>() { "some device token", "another device token" }, /* ScheduleFor = //new PushNotification.ScheduleForBodyList() { new UrbanAirship.NET.Schema.PushNotification.ScheduleForBody() { Time = DateTime.Parse("2010-07-27 22:48:00") } //} * */ ScheduleFor = new DateTime[] { DateTime.Parse("2010-07-27 22:48:00"), DateTime.Parse("2010-07-28 22:48:00") } }; List<JsonConverter> converters = new List<JsonConverter>(); //converters.Add(new SchedulerConverter()); string serializedToken = Newtonsoft.Json.JsonConvert.SerializeObject(push, Newtonsoft.Json.Formatting.None, new Newtonsoft.Json.JsonSerializerSettings() { NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, Converters = converters }); Console.WriteLine("Serialized : " + serializedToken); Helper.AreJsonEqual(expected, serializedToken); }
public void SendNotification(IOSPushNotificationRequest pushRequest) { base.Invoke<IOSPushNotificationRequest, NullResponse>("/api/push/", RestSharp.Method.POST, pushRequest); }
public void TestSchemaIOSAutoUpdate() { string expected = ""+ "{"+ "\"alias\": \"foo\","+ "\"aps\": {"+ "\"badge\": \"auto\","+ "\"alert\": \"My badge is now 4!\""+ "}"; var push = new IOSPushNotificationRequest() { Alias = "foo", APS = new IOSAPSBody() { Badge = "auto", Alert = "My badge is now 4!" }, }; List<JsonConverter> converters = new List<JsonConverter>(); //converters.Add(new SchedulerConverter()); string serializedToken = Newtonsoft.Json.JsonConvert.SerializeObject(push, Newtonsoft.Json.Formatting.None, new Newtonsoft.Json.JsonSerializerSettings() { NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, Converters = converters }); Console.WriteLine("Serialized : " + serializedToken); Helper.AreJsonEqual(expected, serializedToken); }