Esempio n. 1
0
        public static void Main(string[] args)
        {
            var notificationMessage = new NotificationMulticastMessage()
            {
                Payload = new NotificationPayload()
                {
                    Body = "Body",
                    Color = "Color"
                },
                TimeToLive = System.TimeSpan.FromMinutes(1)
            };

            var dataMessage = new DataMulticastMessage()
            {
                RegistrationIds = new[] { "1" },
                Payload = new
                {
                    A = new
                    {
                        a = 1,
                        b = 2
                    },
                    B = 2,
                }
            };

            var client = new GcmServiceClient(new Settings());

            SendMessage(client, notificationMessage);
            SendMessage(client, dataMessage);
        }
Esempio n. 2
0
        private static void SendMessage(GcmServiceClient client, DataMulticastMessage message)
        {
            CancellationTokenSource cts = new CancellationTokenSource();

            var result = client.SendAsync(message, cts.Token).Result;
        }