title: iOS UILocalNotification not being displayed while app in background
body: <p><strong>FIXED</strong> &mdash; Ok, found what it was, there was an errant <code>[[UIApplication sharedApplication] cancelAllLocalNotifications];</code> being fired when I wasn't expecting it.</p>
  
  <p>Well there's your problem.</p>
  
  <p>Thanks for the help everyone, sorry to have it turn out to just be dumb coder syndrome.</p>
  
  <p>I've built out my local notification like so:</p>
  
  <pre><code>- (void)scheduleNotification {
      [[UIApplication sharedApplication] cancelAllLocalNotifications];
      Class cls = NSClassFromString(@"UILocalNotification");
      if (cls != nil) {
          UILocalNotification *notif = [[cls alloc] init];
          NSLog(@"%@", [NSDate date]);
          notif.fireDate = [NSDate dateWithTimeIntervalSinceNow:10];
  
          notif.alertBody = NSLocalizedString(@"Hello.", nil);
  
          [[UIApplication sharedApplication] scheduleLocalNotification:notif];
          NSLog(@"Notification scheduled at %@", notif.fireDate);
          [notif release];
      }
  }
  </code></pre>
  
  <p>As expected my debug log outputs the correct fireDate 10 seconds in the future. If I don't leave my app I get a successful <code>application:didReceiveLocalNotification:</code> callback.</p>
  
  <p>The hiccup here is if I push the button to schedule this notification and hit the home button to put it in the background. If I do this, the notification never fires and I never get an alert view from the OS.</p>
  
  <p>Did I miss something obvious here? I've looked up and down here and the Apple docs and feel I've missed something obvious.</p>
  
  <p>Any help would be greatly appreciated. Thanks.</p>