【问题标题】:Iphone simulator : Local Notification fires twice but never displays?Iphone 模拟器:本地通知触发两次但从不显示?
【发布时间】: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)}

【问题讨论】:

    标签: notifications ios-simulator localnotification


    【解决方案1】:

    如果您在应用运行时收到本地/推送通知,您将不会看到任何警报。除非您在应用程序中显示您自己的警报:didReceiveLocalNotification:,当然。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-10-23
      • 2011-04-05
      • 2021-10-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-12
      相关资源
      最近更新 更多