Esempio n. 1
0
        public GcmMessageResponse SendMessage(GcmMessage message)
        {
            GcmMessageResponse response = Send <GcmMessage, GcmMessageResponse>(message, GCM_SEND_URL);

            response.Message = message;
            UpdateResponseStatusForGcmMessage(response);
            return(response);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            string AuthKey = "AIzaSyDZD29PWZQBmSvW0vAYIu0mvkg2ny5TD9A";
            string PackageName = "com.mydealerlot.mdlmobile";
            string SenderId = "595292508198";
            GcmManagerOptions options = new GcmManagerOptions() { 
                AuthenticationKey = AuthKey, 
                PackageName = PackageName,
                SenderId = SenderId,
                Expect100Continue = false, //default
                UseNagleAlgorithm = false //default
            };

            GcmManager manager = new GcmManager(options);

            GcmMessage message = new GcmMessage().To("RegistrationTokenHere")
                .WithData(new { body = "Client: MR. SMITH, Appointment Time: today 3:00pm", title = "Your Appointment Has Arrived" })
                .WithNotification(new GcmNotification().WithBody("body text here").WithTitle("Title Here"));
               // ;
                //.WithRestrictedPackageName(PackageName).WithTimeToLive(400)
                //.WithIcon("myIcon.png").WithColor("color"));


            Stopwatch watch = new Stopwatch();
            Console.ReadKey();
            //for (int i = 0; i < 10; i++)
            //{
                watch.Start();
                Console.WriteLine("getting instance response");

                GcmMessageResponse response = manager.SendMessage(message);
                //var r = manager.GetInstanceIdResponse(true, "APA91bEVUAdCF4XdfV6cnecuih5SY48lePF8ZCiBgL8fgqRlB9CKlRyZbqOpfOOfP3SkOG2VYH1LDrYi80aotHg1at6QdcDrk_2t1_Iopw7MAkjv0dD-4DCbyqw7qKpF7INfiRQ2u_Ax");
                //Console.WriteLine(r.ToString());

                watch.Stop();
                Console.WriteLine("\nOVERALL: {0}\n\n", watch.Elapsed);
                watch.Reset();
            //}
            
            //bool again = true;
            //while(again)
            //{

            //Console.WriteLine("ready?");
            //Console.ReadLine();
            // var response = manager.SendMessage(message);
            string data = JsonConvert.SerializeObject(message, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore});
            Console.WriteLine(data);
            Debug.WriteLine(data);
            //Console.WriteLine("\n again?");
            //var s = Console.ReadLine();
            //if (s.Contains("no"))
            //    again = false;
            //}
            Console.ReadKey();


        }
Esempio n. 3
0
 public static GcmMessage WithRegistrationId(this GcmMessage msg, string id)
 {
     if (msg.RegistrationIds == null)
     {
         msg.RegistrationIds = new List <string>();
     }
     msg.RegistrationIds.Add(id);
     return(msg);
 }
Esempio n. 4
0
 public static GcmMessage WithRegistrationIds(this GcmMessage msg, List <string> ids)
 {
     if (msg.RegistrationIds == null)
     {
         msg.RegistrationIds = new List <string>();
     }
     msg.RegistrationIds.AddRange(ids);
     return(msg);
 }
Esempio n. 5
0
 public static GcmMessage WithDeliveryReceiptRequested(this GcmMessage msg, bool deliveryReceiptRequested)
 {
     msg.DeliveryReceiptRequested = deliveryReceiptRequested;
     return(msg);
 }
Esempio n. 6
0
 public static GcmMessage WithTimeToLive(this GcmMessage msg, int timeToLive)
 {
     msg.TimeToLive = timeToLive;
     return(msg);
 }
Esempio n. 7
0
 public static GcmMessage WithDelayWhileIdle(this GcmMessage msg, bool delayWhileIdle)
 {
     msg.DelayWhileIdle = delayWhileIdle;
     return(msg);
 }
Esempio n. 8
0
 public static GcmMessage WithContentAvailable(this GcmMessage msg, bool contentAvailable)
 {
     msg.ContentAvailable = contentAvailable;
     return(msg);
 }
Esempio n. 9
0
 public GcmException(string message, GcmMessage gcmMessage)
     : base(message)
 {
     Message = gcmMessage;
 }
Esempio n. 10
0
 public GcmException(string message, Exception innerException, GcmMessage gcmMessage)
     : base(message, innerException) { Message = gcmMessage; }
Esempio n. 11
0
 public GcmManagerTimeoutException(string message, GcmMessage gcmMessage)
     : base(message) { Message = gcmMessage; }
Esempio n. 12
0
 public static GcmMessage WithNotification(this GcmMessage msg, GcmNotification not)
 {
     msg.Notification = not;
     return(msg);
 }
Esempio n. 13
0
 public static GcmMessage To(this GcmMessage msg, string to)
 {
     msg.To = to;
     return(msg);
 }
Esempio n. 14
0
 public static GcmMessage WithData(this GcmMessage msg, object data)
 {
     msg.Data = data;
     return(msg);
 }
Esempio n. 15
0
 public GcmException(string message, Exception innerException, GcmMessage gcmMessage)
     : base(message, innerException)
 {
     Message = gcmMessage;
 }
Esempio n. 16
0
 public static GcmMessage WithRestrictedPackageName(this GcmMessage msg, string packageName)
 {
     msg.RestrictedPackageName = packageName;
     return(msg);
 }
Esempio n. 17
0
 public static GcmMessage IsDryRun(this GcmMessage msg, bool isDryRun)
 {
     msg.DryRun = isDryRun;
     return(msg);
 }
Esempio n. 18
0
 public static GcmMessage WithMessageId(this GcmMessage msg, string id)
 {
     msg.MessageId = id;
     return(msg);
 }
Esempio n. 19
0
 public GcmException(string message, GcmMessage gcmMessage)
     : base(message) { Message = gcmMessage; }
Esempio n. 20
0
 public static GcmMessage WithCollapseKey(this GcmMessage msg, string key)
 {
     msg.CollapseKey = key;
     return(msg);
 }
Esempio n. 21
0
 public static GcmMessage WithPriority(this GcmMessage msg, int priority)
 {
     msg.Priority = priority;
     return(msg);
 }
Esempio n. 22
0
 public GcmManagerTimeoutException(string message, GcmMessage gcmMessage)
     : base(message)
 {
     Message = gcmMessage;
 }