예제 #1
0
        public void PushChannel(string message, string channelId, IComparable badge)
        {
            //Assert.That(!string.IsNullOrWhiteSpace(message));
            Assert.That(!string.IsNullOrWhiteSpace(channelId));

            if (!CHL_TK.IsMatch(channelId))
            {
                string ch = ServiceModelConfig.GetConfigValue(channelId);
                Assert.That(CHL_TK.IsMatch(ch), "Invalid UA Channel Id: {0} => {1}", channelId, ch);
                channelId = ch;
            }

            var p = new Push(new Audience(Type.AudienceType.Ios, channelId, true), message);
            p.Notification.IosAlert = new IosAlert { Badge = badge };

            PushResponse pv = _ua.Validate(p);
            TestResponse(pv);

            PushResponse pr = _ua.Push(p);
            TestResponse(pr);
            CollectionAssert.IsNotEmpty(pr.PushIds);
        }
예제 #2
0
        public void PushToken(string message, string iosDeviceToken, IComparable badge)
        {
            //Assert.That(!string.IsNullOrWhiteSpace(message));
            Assert.That(!string.IsNullOrWhiteSpace(iosDeviceToken));

            if (!DEV_TK.IsMatch(iosDeviceToken))
            {
                string tk = ServiceModelConfig.GetConfigValue(iosDeviceToken);
                Assert.That(DEV_TK.IsMatch(tk), "Invalid iOS Device Token: {0} => {1}", iosDeviceToken, tk);
                iosDeviceToken = tk;
            }

            var p = new Push(new Audience(Type.AudienceType.Ios, iosDeviceToken), message);
            p.Notification.IosAlert = new IosAlert { Badge = badge };

            PushResponse pv = _ua.Validate(p);
            TestResponse(pv);

            PushResponse pr = _ua.Push(p);
            TestResponse(pr);
            CollectionAssert.IsNotEmpty(pr.PushIds);
        }
예제 #3
0
 public PushValidateRequest(Push push, ServiceModelConfig cfg)
     : base(push, cfg)
 {
     RequestUrl = "api/push/validate/";
 }
예제 #4
0
 public PushValidateRequest(Push push)
     : base(push)
 {
     RequestUrl = "api/push/validate/";
 }
예제 #5
0
        private static void TestTags()
        {
            Console.WriteLine("================ TESTING TAGS ================");
            Console.WriteLine();

            const string testTag = "some_tag";

            var tag = new Tag
            {
                TagName = testTag,
                AndroidChannels = new AddRemoveList
                {
                    Add = new[] { "TEST_ANDROID_CHANNEL" }
                }
            };

            Console.WriteLine("CREATE TAG:");
            var response = _urbanAirSharpGateway.CreateTag(tag);
            Console.Write(response.HttpResponseCode + " - ");
            Console.WriteLine(response.Ok ? "SUCCESS" : "FAILED");
            Console.WriteLine();

            Console.WriteLine("LIST TAGS:");
            var listResponse = _urbanAirSharpGateway.ListTags();
            Console.Write(listResponse.HttpResponseCode + " - ");
            Console.WriteLine(listResponse.Ok ? "SUCCESS" : "FAILED");
            Console.WriteLine();

            Console.WriteLine("DELETE TAG:");
            response = _urbanAirSharpGateway.DeleteTag(testTag);
            Console.Write(response.HttpResponseCode + " - ");
            Console.WriteLine(response.Ok ? "SUCCESS" : "FAILED");
            Console.WriteLine();

            var client = new UrbanAirSharpGateway(AppKey, AppMasterSecret);
            var compoundAudience = new Audience(AudienceType.Android, "") & new Audience(AudienceType.Blackberry, "") & new Audience(AudienceType.Android, "");
            compoundAudience &= new Audience(AudienceType.Android, "");

            var moreAudience = new AudienceAnd { Audiences = new[] { new Audience(AudienceType.Tag, ""), new Audience(AudienceType.Tag, "") } };
            compoundAudience &= moreAudience;

            var message = new Push(compoundAudience, "What's up");

            client.Push(new Push("Custom Android Alert per device type", new[]
            {
                new AndroidAlert()
                {
                    Alert = "Custom Android Alert",
                    CollapseKey = "Collapse_Key",
                    DelayWhileIdle = true,
                    GcmTimeToLive = 5
                }
            }));
        }