2010-08-25 5 views
0

Y at-il un bogue avec le simulateur et les notifications locales ou suis-je en train de faire quelque chose de mal?Simulateur Iphone: la notification locale se déclenche deux fois mais ne s'affiche jamais?

// 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 journaux 2 notifications, mais le simulateur n'affiche réellement une 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)} 

Répondre

2

Vous ne verrez aucune alerte si vous recevez une notification locale/push pendant que votre application est en cours d'exécution. Sauf si vous affichez votre propre alerte dans l'application: didReceiveLocalNotification :, certainement.

Questions connexes