/// <summary> /// Create builder with Data that will be sent only to iOS-APNS devices. /// Corresponding to APNS's custom payload. /// The data specified here will be merged with the data specified on <see cref="KiiPushMessage.BuildWith(KiiPushMessage.Data)"/> /// </summary> /// <remarks></remarks> /// <param name="data">APNS specific data.</param> /// <returns>Builder of the message.</returns> /// <exception cref='ArgumentNullException'> /// Is thrown when an argument is null. /// </exception> public Builder WithAPNSData(APNSData data) { if (data == null) { throw new ArgumentNullException("data must not be null"); } this.mData = data; return(this); }
public void Test_0003_APNSMessage() { APNSData data = new APNSData(); data.Put("payload", "abc"); APNSMessage apns = APNSMessage.CreateBuilder() .WithAPNSData(data) .WithAlertActionLocKey("ActionLocKey") .WithAlertBody("Body") .WithAlertLaunchImage("LaunchImage") .WithAlertLocArgs(new string[] { "Args1", "Args2" }) .WithAlertLocKey("LocKey") .WithAlertTitle("title") .WithAlertSubtitle("subtitle") .WithBadge(3) .WithContentAvailable(1) .WithSound("Sound") .WithMutableContent(1) .Build(); JsonObject json = apns.ToJson(); Assert.AreEqual(true, json.Get("enabled")); Assert.AreEqual(3, json.Get("badge")); Assert.AreEqual(1, json.Get("contentAvailable")); Assert.AreEqual(1, json.Get("mutableContent")); Assert.AreEqual("Sound", json.Get("sound")); Assert.AreEqual("abc", json.GetJsonObject("data").Get("payload")); Assert.AreEqual("ActionLocKey", json.GetJsonObject("alert").Get("actionLocKey")); Assert.AreEqual("title", json.GetJsonObject("alert").Get("title")); Assert.AreEqual("subtitle", json.GetJsonObject("alert").Get("subtitle")); Assert.AreEqual("Body", json.GetJsonObject("alert").Get("body")); Assert.AreEqual("LaunchImage", json.GetJsonObject("alert").Get("launchImage")); Assert.AreEqual("Args1", json.GetJsonObject("alert").GetJsonArray("locArgs").Get(0)); Assert.AreEqual("Args2", json.GetJsonObject("alert").GetJsonArray("locArgs").Get(1)); Assert.AreEqual("LocKey", json.GetJsonObject("alert").Get("locKey")); }