views:

48

answers:

2

Is there a bug with the simulator and Local Notifications or am I doing something incorrectly.

// on button click fire off notification for 30 seconds from now
-(IBAction)scheduleNotification{
UILocalNotification *localNotif = [[UILocalNotification alloc] init];

NSDate *item = [NSDate dateWithTimeIntervalSinceNow:30]; 

if (localNotif == nil)
return;     
localNotif.fireDate = item;
localNotif.timeZone = [NSTimeZone defaultTimeZone];
localNotif.alertBody =  NSLocalizedString(@"Test Notification", nil);
localNotif.alertAction = NSLocalizedString(@"View Details", nil);
localNotif.soundName = UILocalNotificationDefaultSoundName;
localNotif.applicationIconBadgeNumber = 0;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
[localNotif release];
}   



- (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notif {
    // Handle the notificaton when the app is running
    NSLog(@"Recieved Notification %@",notif);
}

didReceiveLocalNotification logs 2 notifications, but the simulator never actually displays a notification.

Recieved Notification <UIConcreteLocalNotification: 0x5943450>{fire date = 2010-08-25 09:36:25 -0400, time zone = America/New_York (EDT) offset -14400 (Daylight), repeat interval = 0, next fire date = 2010-08-25 09:36:25 -0400}

Recieved Notification <UIConcreteLocalNotification: 0x5c53e00>{fire date = 2010-08-25 09:36:25 -0400, time zone = America/New_York (EDT) offset -14400 (Daylight), repeat interval = 0, next fire date = (null)}
+2  A: 

It will work correctly in your device. I also face same problem in simulator but it is working correctly in device.

Apoorv
A: 

You won't see any alert if you receive local/push notification while your app is running. Unless you show your own alert in application: didReceiveLocalNotification:, certainly.

dieworld