UILocationNotification is not subject to summer savings

I plan such local notifications

+ (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];
}

However, after the clock went ahead last weekend, the notifications scheduled before the clock went ahead shoot in an hour, i.e. 19:00 instead of 18:00

The apple documentation says that the “wall clock” time sets the time zone as described above.

Any suggestions are welcome.

0
source share
1 answer

Therefore, instead of adding a time interval of 24 hours, I used ..

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

Where

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

This works in most cases if the date is not between midnight and time, when the hours usually change around 2:00 in the morning. There was no need for logic for this, since after that there will be time.

+2
source

All Articles