title: How to send a push notification to more than one device (iOS)?
body: <p>I'm trying to optimize the push notifications on my server. For now I send those one by one (with an old library) and it takes a while (4 hours).</p>
  
  <p>I refactored my service to send a notification with a lot of device tokens (For now I tried with batches of 500 tokens). For that I'm using the <a href="https://github.com/Redth/PushSharp" rel="nofollow" >Redth/PushSharp</a> library. I followed the <a href="https://github.com/Redth/PushSharp/blob/master/PushSharp.Sample/Program.cs" rel="nofollow" >sample code</a> then I adapted it to send the notifications to severals device tokens.</p>
  
  <pre><code>PushService service = new PushService();
  
  //Wire up the events
  service.Events.OnDeviceSubscriptionExpired += new PushSharp.Common.ChannelEvents.DeviceSubscriptionExpired(Events_OnDeviceSubscriptionExpired);
  service.Events.OnDeviceSubscriptionIdChanged += new PushSharp.Common.ChannelEvents.DeviceSubscriptionIdChanged(Events_OnDeviceSubscriptionIdChanged);
  service.Events.OnChannelException += new PushSharp.Common.ChannelEvents.ChannelExceptionDelegate(Events_OnChannelException);
  service.Events.OnNotificationSendFailure += new PushSharp.Common.ChannelEvents.NotificationSendFailureDelegate(Events_OnNotificationSendFailure);
  service.Events.OnNotificationSent += new PushSharp.Common.ChannelEvents.NotificationSentDelegate(Events_OnNotificationSent);
  service.Events.OnChannelCreated += new PushSharp.Common.ChannelEvents.ChannelCreatedDelegate(Events_OnChannelCreated);
  service.Events.OnChannelDestroyed += new PushSharp.Common.ChannelEvents.ChannelDestroyedDelegate(Events_OnChannelDestroyed);
  
  //Configure and start ApplePushNotificationService
  string p12Filename = ...
  string p12FilePassword = ...
  
  var appleCert = File.ReadAllBytes(p12Filename);
  
  service.StartApplePushService(new ApplePushChannelSettings(true, appleCert, p12FilePassword));
  
  var appleNotification = NotificationFactory.Apple();
  
  foreach (var itemToProcess in itemsToProcess)
  {
      itemToProcess.NotificationDateTime = DateTime.Now;
      mobile.SubmitChanges();
  
      string deviceToken = GetCleanDeviceToken(itemToProcess.MobileDevice.PushNotificationIdentifier);
      appleNotification.ForDeviceToken(deviceToken);
  }
  
  service.QueueNotification(appleNotification
      .WithAlert(itemsToProcess[0].MobileDeviceNotificationText.Text)
      .WithSound("default")
      .WithBadge(0)
      .WithCustomItem("View", itemsToProcess[0].Value.ToString()));
  
  //Stop and wait for the queues to drains
  service.StopAllServices(true);
  </code></pre>
  
  <p>Then I tried to send 3 notifications to 2 devices. Only the first device got them (and the problem is not device-related because I tried with both of them separately).
  Right after that an OperationCanceledException is thrown in the <a href="https://github.com/Redth/PushSharp/blob/master/PushSharp.Common/PushChannelBase.cs" rel="nofollow">PushChannelBase class</a>. So I don't know what's wrong. Any idea?</p>