2013-07-28 56 views
0

我得到了以下其中包含我localNotification代碼:我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年7月28日15:39:48.684 JuneChecklist [2271: 907]計劃通知{消防日=星期日,2013 7月28日,十五點40分33秒莫斯科標準時間,時區=歐洲/莫斯科(GMT + 04:00)偏移14400,重複間隔= 0,重複計數爲UILocalNotificationInfiniteRepeatCount ,未來火日期=星期天,2013 7月28日15時40分33秒莫斯科標準時間,用戶信息= { 項目Id = 0; }}爲0的itemId

但它不顯示(我試圖在iPhone和模擬器啓動應用程序)。我不知道爲什麼它的NSLog顯示fireDate完美,但沒有通知時,我等待的時間。

任何意見,將不勝感激。

回答

1

但哪一個[[UIApplication的sharedApplication] scheduleLocalNotification:localNotification];

+0

現在感謝您的工作。這段代碼來自教程,我想知道。 –