title: Push notifications disappear if received while app not running
body: <p>I'm developing an app that can receive push notifications which, in some circumstances, trigger background fetch operations. Therefore, I've enabled the <code>remote-notification</code> background capability for my app.</p>
  
  <p>When the app is suspended, push notifications cause the app to wake up and execute <code>application:didReceiveRemoteNotification:fetchCompletionHandler</code>, the banner appears on the homescreen, and the notification remains in the Notification Center until the user taps it to launch the app. It works exactly as it should.</p>
  
  <p>When the app is not running, a notification will launch the app as long as it was not force-quit by a user (see <a href="https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplicationDelegate_Protocol/#//apple_ref/occ/intfm/UIApplicationDelegate/application:didReceiveRemoteNotification:fetchCompletionHandler:" rel="nofollow">apple's documentation</a>), and the app executes <code>application:didFinishLaunchingWithOptions</code> and <code>application:didReceiveRemoteNotification:fetchCompletionHandler</code>. The banner appears over the homescreen, but then the notification disappears. It does not remain in the Notification Center. Furthermore, if the device is locked, sometimes the notification disappears before it even finishes making the alert sound.</p>
  
  <p>Interestingly, if I disable the remote notification background mode, everything works fine. In that situation, the app is not launched when the push notification arrives.</p>
  
  <p>How can I prevent the notifications from disappearing when remote notification background mode is on, and an incoming notification launches the not-running app? Do I need to include something in <code>application:didFinishLaunchingWithOptions</code> that lets the app know it's being launched in the background, and the notification shouldn't be discarded?</p>