Example #1
0
 public static void SendPushNotificationRequest(PushNotification_Demo notif)
 {
     string registerMethod = "RemoteAPI/CreateNotification";
     string payloadMethod = "RemoteAPI/CheckIosPayload";
     if (notif.validate()) // if validation is OK and we configured all the nececcery fields, we can continue.
     {
         //It is highly recommanded to check iOS payload before sending a notication.
         if (notif.Platforms == null || notif.Platforms.Contains(Enums.DevicePlatform.iOS))
         {   // if platforms is null (means sends to all platforms) or IOS is configured within the platforms
             // user should use this method if the iOS is configured in the application he sends push to in order to
             // prevent an error response when sending notification with high payload (ios payload is limited to 255 Bytes).
             // If Ios is not configured to the current app, iOS payload isn't being checked.
             Payload_Demo payload = new Payload_Demo();
             payload.Message = notif.Message;
             payload.Link = notif.Link;
             payload.CustomJsonKey = notif.CustomJsonKey;
             payload.CustomJson = notif.CustomJson;
             PushAppResponse resp = new PushAppResponse();
             resp = SendRequest(payloadMethod, (Object)payload);
             if (resp.Code.Equals("100"))        // 100 stands for Success
             {
                 SendRequest(registerMethod, (Object)notif);
             }
         }
         else
         {
             SendRequest(registerMethod, (Object)notif);
         }
     }
 }
        public static void SendPushNotificationRequest(PushNotification_Demo notif)
        {
            string registerMethod = "RemoteAPI/CreateNotification";
            string payloadMethod  = "RemoteAPI/CheckIosPayload";

            if (notif.validate()) // if validation is OK and we configured all the nececcery fields, we can continue.
            {
                //It is highly recommanded to check iOS payload before sending a notication.
                if (notif.Platforms == null || notif.Platforms.Contains(Enums.DevicePlatform.iOS))
                {   // if platforms is null (means sends to all platforms) or IOS is configured within the platforms
                    // user should use this method if the iOS is configured in the application he sends push to in order to
                    // prevent an error response when sending notification with high payload (ios payload is limited to 255 Bytes).
                    // If Ios is not configured to the current app, iOS payload isn't being checked.
                    Payload_Demo payload = new Payload_Demo();
                    payload.SecretToken   = notif.SecretToken;
                    payload.Message       = notif.Message;
                    payload.Link          = notif.Link;
                    payload.CustomJsonKey = notif.CustomJsonKey;
                    payload.CustomJson    = notif.CustomJson;
                    PushAppResponse resp = new PushAppResponse();
                    resp = SendRequest(payloadMethod, (Object)payload);
                    if (resp.Code.Equals("100"))        // 100 stands for Success
                    {
                        SendRequest(registerMethod, (Object)notif);
                    }
                }
                else
                {
                    SendRequest(registerMethod, (Object)notif);
                }
            }
        }