title: Local notification on application termination
body: <p>I am working on an application which will not work if terminated. It has some background tasks. I want to show a local notification if the app is terminated. There are applications which do this which means this is doable. But I am not able to find out a way.</p>
  
  <p>I have tried to set up a local notification in applicationWillTerminate: method of appdelegate as well as added a notification of app termination in my viewcontroller but none of the methods get called when app is actually terminated.</p>
  
  <pre><code>- (void)applicationWillTerminate:(UIApplication *)application
  {
      NSLog(@"terminated");
      UIApplication * app = [UIApplication sharedApplication];
      NSDate *date = [[NSDate date] dateByAddingTimeInterval:15];
      UILocalNotification *alarm = [[UILocalNotification alloc] init] ;
      if (alarm) {
          alarm.fireDate = [NSDate date];
          alarm.timeZone = [NSTimeZone defaultTimeZone];
          alarm.repeatInterval = 0;
          alarm.alertBody = @"This app does not work if terminated";
          alarm.alertAction = @"Open";
          [app scheduleLocalNotification:alarm];
      }
  
      [app presentLocalNotificationNow:alarm];
      // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
  }
  </code></pre>
  
  <p>Any help would be great.</p>
  
  <p>Thanks in Advance !!!</p>