模拟器和本地通知是否有错误,或者我做错了什么。
// 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)}
答案 0 :(得分:2)
如果您在应用运行时收到本地/推送通知,则不会看到任何提醒。除非你在应用程序中显示自己的警报:didReceiveLocalNotification:,当然。