I have following line of code to generate local notification after every 1 minute (For Testing), It works perfectly in following condition.
- When application is in running state.
- When application is in background state and and localNotification.alertBody = @”Local Notification Received” is not commented.
Now when i comment the “localNotification.alertBody” it works fine when application is in running state but didn’t work when application is in background state.
Following is the line of code to create local notification.
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
[localNotification setRepeatInterval:NSMinuteCalendarUnit];
localNotification.timeZone = [NSTimeZone defaultTimeZone];
localNotification.repeatCalendar = [NSCalendar currentCalendar];
localNotification.fireDate = fireDateOfNotification;
//localNotification.alertBody = @"Local Notification Received";
localNotification.repeatInterval = NSMinuteCalendarUnit;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
[localNotification release];
in – (void)applicationDidEnterBackground:(UIApplication *)application
bgTask = [application beginBackgroundTaskWithExpirationHandler: ^{
dispatch_async(dispatch_get_main_queue(), ^{
[application endBackgroundTask:self->bgTask];
self->bgTask = UIBackgroundTaskInvalid;
It seems that you are trying to execute code in the background, without showing a notification to the user.
By definition, UILocalNotification will not display a popup if alertBody is nil, even though didReceiveLocalNotification will be called PROVIDED THAT THE APPLICATION IS RUNNING.
If the application is in the background and alertBody is empty, then no popup alert and no execution of any code.