コード例 #1
0
        private static void TestSchedules()
        {
            Console.WriteLine("================ TESTING SCHEDULES ================");
            Console.WriteLine();

            var schedule = new Schedule
            {
                Name         = "TEST_SCHEDULE",
                ScheduleInfo = new ScheduleInfo
                {
                    ScheduleTime = DateTime.Now.AddMinutes(5)
                },
                Push = UrbanAirSharpGateway.CreatePush("Scheduled Push")
            };

            Console.WriteLine("CREATE SCHEDULE:");
            var createResponse = _urbanAirSharpGateway.CreateSchedule(schedule);

            Console.Write(createResponse.HttpResponseCode + " - ");
            Console.WriteLine(createResponse.Ok ? "SUCCESS" : "FAILED");
            Console.WriteLine();

            Console.WriteLine("LIST SCHEDULES:");
            var listResponse = _urbanAirSharpGateway.ListSchedules();

            Console.Write(listResponse.HttpResponseCode + " - ");
            Console.WriteLine(listResponse.Ok ? "SUCCESS" : "FAILED");
            Console.WriteLine();

            var scheduleId = Guid.NewGuid();

            if (createResponse.Ok && createResponse.Schedules.Count > 0)
            {
                scheduleId = createResponse.Schedules[0].Id;
            }

            Console.WriteLine("GET SCHEDULE:");
            var getResponse = _urbanAirSharpGateway.GetSchedule(scheduleId);

            Console.Write(getResponse.HttpResponseCode + " - ");
            Console.WriteLine(getResponse.Ok ? "SUCCESS" : "FAILED");
            Console.WriteLine();

            Console.WriteLine("DELETE SCHEDULE:");
            var deleteResponse = _urbanAirSharpGateway.DeleteSchedule(scheduleId);

            Console.Write(deleteResponse.HttpResponseCode + " - ");
            Console.WriteLine(deleteResponse.Ok ? "SUCCESS" : "FAILED");
            Console.WriteLine();
        }
コード例 #2
0
        public async Task <bool> SendTimed(string namedUserId, MessagePush pushData, long queueId, DateTime time)
        {
            var jData = JObject.FromObject(pushData);
            var paramaterDictionary = new Dictionary <string, string>();

            paramaterDictionary.Add("Id", pushData.Id.ToString());
            paramaterDictionary.Add("Type", pushData.PushType.ToString());
            var push = UrbanAirSharpGateway.CreatePush(pushData.Title, new List <UrbanAirSharp.Type.DeviceType>()
            {
                UrbanAirSharp.Type.DeviceType.Ios, UrbanAirSharp.Type.DeviceType.Android
            }, null, new List <BaseAlert>()
            {
                new AndroidAlert()
                {
                    Alert          = pushData.Title,
                    DelayWhileIdle = true,
                    GcmTimeToLive  = 3600,
                    Extras         = paramaterDictionary
                },
                new IosAlert()
                {
                    Alert            = pushData.Title,
                    ContentAvailable = true,
                    ApnsTimeToLive   = 3600,
                    Extras           = paramaterDictionary
                }
            }, new Audience(UrbanAirSharp.Type.AudienceType.NamedUser, namedUserId));

            var result = await client.CreateScheduleAsync(new Schedule()
            {
                Push         = push,
                ScheduleInfo = new ScheduleInfo()
                {
                    ScheduleTime = time
                }
            });

            return(result.Ok);
        }