public GcmMessageResponse SendMessage(GcmMessage message)
        {
            GcmMessageResponse response = Send <GcmMessage, GcmMessageResponse>(message, GCM_SEND_URL);

            response.Message = message;
            UpdateResponseStatusForGcmMessage(response);
            return(response);
        }
Exemple #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();


        }
 public static GcmMessage WithRegistrationId(this GcmMessage msg, string id)
 {
     if (msg.RegistrationIds == null)
     {
         msg.RegistrationIds = new List <string>();
     }
     msg.RegistrationIds.Add(id);
     return(msg);
 }
 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);
 }
 public static GcmMessage WithDeliveryReceiptRequested(this GcmMessage msg, bool deliveryReceiptRequested)
 {
     msg.DeliveryReceiptRequested = deliveryReceiptRequested;
     return(msg);
 }
 public static GcmMessage WithTimeToLive(this GcmMessage msg, int timeToLive)
 {
     msg.TimeToLive = timeToLive;
     return(msg);
 }
 public static GcmMessage WithDelayWhileIdle(this GcmMessage msg, bool delayWhileIdle)
 {
     msg.DelayWhileIdle = delayWhileIdle;
     return(msg);
 }
 public static GcmMessage WithContentAvailable(this GcmMessage msg, bool contentAvailable)
 {
     msg.ContentAvailable = contentAvailable;
     return(msg);
 }
Exemple #9
0
 public GcmException(string message, GcmMessage gcmMessage)
     : base(message)
 {
     Message = gcmMessage;
 }
Exemple #10
0
 public GcmException(string message, Exception innerException, GcmMessage gcmMessage)
     : base(message, innerException) { Message = gcmMessage; }
Exemple #11
0
 public GcmManagerTimeoutException(string message, GcmMessage gcmMessage)
     : base(message) { Message = gcmMessage; }
 public static GcmMessage WithNotification(this GcmMessage msg, GcmNotification not)
 {
     msg.Notification = not;
     return(msg);
 }
 public static GcmMessage To(this GcmMessage msg, string to)
 {
     msg.To = to;
     return(msg);
 }
 public static GcmMessage WithData(this GcmMessage msg, object data)
 {
     msg.Data = data;
     return(msg);
 }
Exemple #15
0
 public GcmException(string message, Exception innerException, GcmMessage gcmMessage)
     : base(message, innerException)
 {
     Message = gcmMessage;
 }
 public static GcmMessage WithRestrictedPackageName(this GcmMessage msg, string packageName)
 {
     msg.RestrictedPackageName = packageName;
     return(msg);
 }
 public static GcmMessage IsDryRun(this GcmMessage msg, bool isDryRun)
 {
     msg.DryRun = isDryRun;
     return(msg);
 }
 public static GcmMessage WithMessageId(this GcmMessage msg, string id)
 {
     msg.MessageId = id;
     return(msg);
 }
Exemple #19
0
 public GcmException(string message, GcmMessage gcmMessage)
     : base(message) { Message = gcmMessage; }
 public static GcmMessage WithCollapseKey(this GcmMessage msg, string key)
 {
     msg.CollapseKey = key;
     return(msg);
 }
 public static GcmMessage WithPriority(this GcmMessage msg, int priority)
 {
     msg.Priority = priority;
     return(msg);
 }
Exemple #22
0
 public GcmManagerTimeoutException(string message, GcmMessage gcmMessage)
     : base(message)
 {
     Message = gcmMessage;
 }