0

我得到以下代码,其中包含我的 localNotification:

-(void)scheduleNotification{

    if (self.shouldRemind && [self.dueDate compare:[NSDate date]] != NSOrderedAscending){

        UILocalNotification *localNotification = [UILocalNotification new];
        localNotification.fireDate = self.dueDate;
        localNotification.timeZone = [NSTimeZone defaultTimeZone];
        localNotification.alertBody = self.text;
        localNotification.soundName = UILocalNotificationDefaultSoundName;
        localNotification.userInfo = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:self.itemId] forKey:@"ItemId"];

        NSLog(@"Scheduled notification %@ for itemId %d", localNotification, self.itemId);

    }
}

我在 NSLog 中的输出如下:

2013-07-28 15:39:48.684 JuneChecklist[2271:907] 预定通知 {fire date = воскресенье, 28 июля 2013 г., 15:40:33 Московское стандартное время, time zone = Europe/Moscow (GMT+0 00) 偏移量 14400,重复间隔 = 0,重复计数 = UILocalNotificationInfiniteRepeatCount,下一次触发日期 = воскресенье,28 июля 2013 г.,15:40:33 Московское стандартное время,用户信息 = { ItemId = 0; }} 为 itemId 0

但它没有显示(我尝试在 iPhone 和模拟器上启动应用程序)。我想知道为什么它在 NSLog 中完美地显示了 fireDate,但是当我等待那个时间时没有通知。

任何意见,将不胜感激。

4

1 回答 1

1

但是 [[UIApplication sharedApplication] scheduleLocalNotification:localNotification]; 在哪里?

于 2013-07-28T11:51:12.060 回答