title: Push Notifications with PushSharp - the basics
body: <p>I need to push notifications to tens of thousands of iOS devices that my app installed.  I'm trying to do it with PushSharp, but I'm missing some fundamental concepts here.  At first I tried to actually run this in a Windows service, but couldn't get it work - getting null reference errors coming from _push.QueueNotification() call.  Then I did exactly what the documented sample code did and it worked: </p>
  
  <pre><code>    PushService _push = new PushService();
  
      _push.Events.OnNotificationSendFailure += new ChannelEvents.NotificationSendFailureDelegate(Events_OnNotificationSendFailure);
      _push.Events.OnNotificationSent += new ChannelEvents.NotificationSentDelegate(Events_OnNotificationSent);
  
      var cert = File.ReadAllBytes(HttpContext.Current.Server.MapPath("..pathtokeyfile.p12"));
  
      _push.StartApplePushService(new ApplePushChannelSettings(false, cert, "certpwd"));
  
      AppleNotification notification = NotificationFactory.Apple()
                                                          .ForDeviceToken(deviceToken)
                                                          .WithAlert(message)
                                                          .WithSound("default")
                                                          .WithBadge(badge);
      _push.QueueNotification(notification);
  
      _push.StopAllServices(true);
  </code></pre>
  
  <p><strong>Issue #1</strong>: 
  This works perfectly and I see the notification pop up on the iPhone.  However, since it's called a Push Service, I assumed it would behave like a service - meaning, I instantiate it and call _push.StartApplePushService() within a Windows service perhaps.  And I thought to actually queue up my notifications, I could do this on the front-end (admin app, let's say): </p>
  
  <pre><code>        PushService push = new PushService();
  
          AppleNotification notification = NotificationFactory.Apple()
                                                              .ForDeviceToken(deviceToken)
                                                              .WithAlert(message)
                                                              .WithSound("default")
                                                              .WithBadge(badge);
          push.QueueNotification(notification);
  </code></pre>
  
  <p>Obviously (and like I already said), it didn't work - the last line kept throwing a null reference exception. </p>
  
  <p>I'm having trouble finding any other kind of documentation that would show how to set this up in a service/client manner (and not just call everything at once).  Is it possible or am I missing the point of how PushSharp should be utilized?</p>
  
  <p><strong>Issue #2</strong>:
  Also, I can't seem to find a way to target many device tokens at once, without looping through them and queuing up notifications one at a time.  Is that the only way or am I missing something here as well? </p>
  
  <p>Thanks in advance.</p>