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] スケジュールされた通知 {発火日 = 2013 年 9 月 28 日、15:40:33 Московское стандартное время、タイム ゾーン = ヨーロッパ/モスクワ (GMT+04: 00) オフセット 14400、繰り返し間隔 = 0、繰り返し回数 = UILocalNotificationInfiniteRepeatCount、次の発火日 = 2013 年 1 月 28 日、15:40:33 午前 15:40:33、ユーザー情報 = {ItemId = 0; }} itemId 0 の場合

しかし、それは表示されません(iPhoneとシミュレーターでアプリを起動しようとしました)。どうして NSLog に fireDate が完全に表示されたのか不思議ですが、その時を待っても通知がありません。

アドバイスをいただければ幸いです。

4

1 に答える 1

1

しかし、[[UIApplication sharedApplication] scheduleLocalNotification:localNotification]; はどこにありますか?

于 2013-07-28T11:51:12.060 に答える