public HttpResponseMessage Post(MessageModel messageObject)
        {
            var users = messageObject.users_keys;
            var message = messageObject.message;

            var jsonNotification = new IonicUserPush();

            using (WebClient wc = new WebClient())
            {
                wc.Headers[HttpRequestHeader.ContentType] = "application/json";
                wc.Headers.Add("X-Ionic-Application-Id", NotificationsControllerSettings.IonicApplicationId);

                try
                {
                    var response = wc.UploadString(new Uri("https://push.ionic.io/api/v1/push"),
                        JsonConvert.SerializeObject(jsonNotification));

                    LogService.LogNotification(messageObject, jsonNotification);
                }
                catch (WebException e)
                {
                    Console.WriteLine(e.Message);
                    LogService.LogNotification(messageObject, e.Message);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    LogService.LogNotification(messageObject, e.Message);
                    return null;
                }
            }
            
            return null;
        }
Ejemplo n.º 2
0
 public static void LogNotification(MessageModel serverMessage, IonicUserPush ionicMessage)
 {
     return;
 }