title: ios webview - how to check notifications when the app is not running
body: <p>For my app, I'm using a webview. I have implemented the notifications by following this tutorial :</p>
  
  <p><a href="http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1" rel="nofollow">http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1</a></p>
  
  <p>In my website I use a js code that check new event added in the db:</p>
  
  <pre><code>function checkNotification() 
  {
    $.ajax({
             url: '/checkNewMessages',
             type: "GET",
             success: function (result) 
             {
                // if new event, then I run the #c code below to tell
                // the APN server to send the notif to the device.
             }
           });
  }
  </code></pre>
  
  <p>To send the notifications I'm using a #c code:</p>
  
  <pre><code>var deviceToken = "2191a536a52445046797a871fe3c4cf...";
  var message = "this is a notification.";
  var badge = 1;
  var password = "blablabla";
  var payload = new NotificationPayload(deviceToken, message, badge);
  var notificationList = new List&lt;NotificationPayload&gt;() { payload };
  var push = new PushNotification(true, "apn_developer_identity.p12", password);
  var result = push.SendToApple(notificationList);
  </code></pre>
  
  <p>And I check this every 10000 milisec</p>
  
  <pre><code>setInterval(checkNotification, 10000);
  </code></pre>
  
  <p>But this js code will be running only when the user is on the app. What's happen when the app is not running ? The user won't be able to receive the notifications ? I need a script always running in background checking new event on my db. What is the best way to do this ? Thanks for your help.</p>