internal Builder(KiiPushMessageData messageData)
 {
     this.mParent      = new JsonObject();
     this.mMessageData = messageData;
     this.mGcm         = GCMMessage.CreateBuilder().Build().ToJson();
     this.mApns        = APNSMessage.CreateBuilder().Build().ToJson();
     this.mMqtt        = MqttMessage.CreateBuilder().Build().ToJson();
 }
 /// <summary>
 /// Build with APNS specific message that will be delivered through APNS.
 /// Override the APNS delivery flag if already set by <see cref="EnableAPNS(bool)"/>
 ///
 /// </summary>
 /// <remarks></remarks>
 /// <param name="message">Message.</param>
 /// <returns>Builder of the message.</returns>
 /// <exception cref='ArgumentNullException'>
 /// Is thrown when an argument is null.
 /// </exception>
 public Builder WithAPNSMessage(APNSMessage message)
 {
     if (message == null)
     {
         throw new ArgumentNullException("APNSMessage can not be null");
     }
     this.mApns = message.ToJson();
     return(this);
 }
Esempio n. 3
0
        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"));
        }
Esempio n. 4
0
 public void Test_BuildWithNullSound()
 {
     APNSMessage.CreateBuilder().WithSound(null);
 }
Esempio n. 5
0
 public void Test_BuildWithNullAPNSData()
 {
     APNSMessage.CreateBuilder().WithAPNSData(null);
 }
Esempio n. 6
0
 public void Test_BuildWithNullAlertLocKey()
 {
     APNSMessage.CreateBuilder().WithAlertLocKey(null);
 }
Esempio n. 7
0
 public void Test_BuildWithNullAlertLaunchImage()
 {
     APNSMessage.CreateBuilder().WithAlertLaunchImage(null);
 }