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); } } }
/** * Method is simulating a push notification request being sent to PushApps server. * including validations that needs to be done before sending notification. */ public static void SendPushNotification() { PushNotification_Demo notification = new PushNotification_Demo(); notification.SecretToken = SecretToken; notification.Message = "Hellow World"; // an empty list will send to all available platforms. notification.Platforms = new List<Enums.DevicePlatform>(); notification.Platforms.Add(Enums.DevicePlatform.Android); // in case you want to choose only one platform and not send all notification.Platforms.Add(Enums.DevicePlatform.iOS); // in case you want to choose only one platform and not send all /* in case you want to send to custom devices list. * notification.Devices = new List<Device>(); * Device User = new Device(); * User.DeviceType = Enums.DevicePlatform.Android; // can be also Enums.DevicePlatform.iOS * User.PushToken = "Enter Push Token Here"; */ /* * Paltforms specific features */ notification.PlatformFeatures = new PlatforeFeatures(); notification.PlatformFeatures.AndroidTitle = "some Android title"; //notification.PlatformFeatures.AndroidSound = "sound file without extension"; notification.PlatformFeatures.iOSBadge = 1; //notification.PlatformFeatures.iOSSound = "sound file without extension"; notification.Type = Enums.NotificationType.Immediate; // Currently the only option available in the remote API. ActionsManager.SendPushNotificationRequest(notification); }
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); } } }
/** * Method is simulating a push notification request being sent to PushApps server. * including validations that needs to be done before sending notification. * Pay attention that only 1 of the audience option is allowed: either By Platforms OR Devices OR customIds OR DeviceIds. */ public static void SendPushNotification() { PushNotification_Demo notification = new PushNotification_Demo(); notification.SecretToken = SecretToken; notification.Message = "Hello World"; // an empty list will send to all available platforms. notification.Platforms = new List<Enums.DevicePlatform>(); notification.Platforms.Add(Enums.DevicePlatform.Android); // in case you want to choose only one platform and not send all notification.Platforms.Add(Enums.DevicePlatform.iOS); // in case you want to choose only one platform and not send all /* in case you want to send to custom devices list. * notification.Devices = new List<Device>(); * Device User = new Device(); * User.DeviceType = Enums.DevicePlatform.Android; // can be also Enums.DevicePlatform.iOS * User.PushToken = "Enter Push Token Here"; */ /* in case you want to send to custom list of Device ids * notification.DeviceIds = new List<string>(); * notification.DeviceIds.Add("30010501023"); * notification.DeviceIds.Add("44557015744"); */ /* in case you want to send to a list of Custom ids you provided eariler. * notification.CustomIds = new List<string>(); * notification.CustomIds.Add("IosDevice1"); * notification.CustomIds.Add("AndroidDevice10"); */ /* * Platforms specific features, Null in sound means no sound will be sent causing device to get silent notification. */ notification.PlatformFeatures = new PlatforeFeatures(); notification.PlatformFeatures.AndroidTitle = "Some Android Title"; //notification.PlatformFeatures.AndroidSound = "sound file without extension"; notification.PlatformFeatures.iOSBadge = 1; //can be changed to every number. //notification.PlatformFeatures.iOSSound = "sound file without extension"; ActionsManager.SendPushNotificationRequest(notification); }