2010-08-25 56 views
0

模擬器和本地通知是否存在錯誤,或者我是否做了不正確的事情。Iphone模擬器:本地通知會觸發兩次,但從不顯示?

// 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日誌2個通知,但模擬器實際上從未顯示通知。

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

如果您的應用運行時收到本地/推送通知,則不會看到任何提示。除非您在應用程序中顯示自己的警報:didReceiveLocalNotification:當然。

相關問題