title: Local notification when background task about to expired
body: <p>Can iOS app schedule local notification when background task is about to expired?
  Basically i have some server side ongoing download when app enters to background using NSOperationQueue.<br>
  What i want is to notify user by Local notification when background tasks are about to finish.So that user can bring app to foreground to keep continuing server data download<br>
  Below is code i am being using but i didnt see any local notification </p>
  
  <pre><code>UIBackgroundTaskIdentifier bgTask = [application beginBackgroundTaskWithExpirationHandler: ^{
          dispatch_async(dispatch_get_main_queue(), ^{
             /*TO DO
              prompt the user if they want to continue syncing through push notifications. This will get the user to essentially wake the app so that sync can continue.
               */
              // create the notification and then set it's parameters
              UILocalNotification *beginNotification = [[[UILocalNotification alloc] init] autorelease];
              if (beginNotification) {
                  beginNotification.fireDate = [NSDate date];
                  beginNotification.timeZone = [NSTimeZone defaultTimeZone];
                  beginNotification.repeatInterval = 0;
                  beginNotification.alertBody = @"App is about to exit .Please bring app to background to continue dowloading";
                  beginNotification.soundName = UILocalNotificationDefaultSoundName;
                  // this will schedule the notification to fire at the fire date
                  //[app scheduleLocalNotification:notification];
                  // this will fire the notification right away, it will still also fire at the date we set
                  [application scheduleLocalNotification:beginNotification];
              }
  
              [application endBackgroundTask:self-&gt;bgTask];
              self-&gt;bgTask = UIBackgroundTaskInvalid;
          });
      }];
  </code></pre>