2

私はそのようにローカル通知をスケジュールしています

+ (void) addLocalNotification: (Event *) event {
  UILocalNotification *localNotif = [[UILocalNotification alloc] init];
  localNotif.fireDate = event.scheduleTime;
  localNotif.alertBody = @"Time to apply drops\nPlease press view to see details";
  localNotif.soundName = ALARM_SOUND_FILE;
  localNotif.timeZone = [NSTimeZone localTimeZone];
  localNotif.applicationIconBadgeNumber = 1;
  NSDictionary * dict = [NSDictionary    dictionaryWithObjectsAndKeys:event.number,LN_EVENT_KEY,  ACTION_EVENT, LN_ACTION_KEY,  nil];
  localNotif.userInfo = dict;
  [[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
}

ただし、先週末に時計が進むと、時計が進む前にスケジュールされていた通知が 1 時間遅れて発生します。つまり、18:00 ではなく 19:00 になります。

Apple のドキュメントには、上記のようにタイム ゾーンを設定した「ウォール クロック」時間を取得するように記載されています。

どんな提案も歓迎します。

4

1 に答える 1

2

だから私が使用した24時間の時間間隔を追加するのではなく..

+ (NSDate *) addOneDayToDate: (NSDate *) date {
   return [currentCalendar dateByAddingComponents:oneDay toDate:date options:0];
}

どこ

 oneDay = [[NSDateComponents alloc] init];
 [oneDay setDay:1];
 currentCalendar = [NSCalendar currentCalendar];

これは、日付が午前 0 時から時計が変わる時刻 (通常は午前 2 時頃) まででない限り、ほとんどの場合に機能します。日時はこの後になるため、これにロジックは必要ありません。

于 2013-04-05T15:17:54.713 に答える