My program uses PushSharp to send Apple and GCM push notifications to a list of recipients. I simply loop through all recipients and use the usual QueueNotification
for sending the Push:
Code for iOS push:
var appleBroker = new ApnsServiceBroker(appleConfig);
appleBroker.OnNotificationSucceeded += NotificationSent;
appleBroker.OnNotificationFailed += NotificationFailed;
appleBroker.Start();
string payload = "{\"aps\":{\"alert\":\"" + this.pushMessage.MessageIOS.Replace("\"", "") + "\",\"sound\" : \"sound.caf\"}}";
appleBroker.QueueNotification(new ApnsNotification
{
DeviceToken = deviceId,
Tag = key,
Payload = JObject.Parse(payload)
});
appleBroker.Stop();
There is also a similar version for GCM push messages.
Problem is, as the number of recipients increase, so does the sending time. One solution I thought of was to do the queuing in separate threats. But then the question is what becomes a limit of separate threats if there are say 500,000 recipients. This can become very heavy on the processor.
I am wondering if there is a way to send a list of notifications at once instead of one a time?