Iphone 模拟器:本地通知触发两次但从不显示?
Posted
技术标签:
【中文标题】Iphone 模拟器:本地通知触发两次但从不显示?【英文标题】:Iphone simulator : Local Notification fires twice but never displays? 【发布时间】:2010-08-25 13:54:45 【问题描述】:模拟器和本地通知是否存在错误,或者我做错了什么。
// 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)
【问题讨论】:
【参考方案1】:如果您在应用运行时收到本地/推送通知,您将不会看到任何警报。除非您在应用程序中显示您自己的警报:didReceiveLocalNotification:,当然。
【讨论】:
以上是关于Iphone 模拟器:本地通知触发两次但从不显示?的主要内容,如果未能解决你的问题,请参考以下文章