Local notifications not adjusting for timezones

前端 未结 2 808
逝去的感伤
逝去的感伤 2021-02-09 11:47

I\'m scheduling a local notification with an NSDate with the time set to 9pm and am setting the notification\'s timezone to UTC/GMT.

If I set the device timezone to UTC

相关标签:
2条回答
  • 2021-02-09 12:03

    This doesn't seem be the case for daylight savings change. I have some repeating notifications with the timezone set to the localTimeZone but since this last weekend when the clocks went forward an hour they are firing an hour later, ie at 19:00 instead of 18:00.

    Seems like when I schedule an event I will have to determine the timezone for that date and use that.

    Thanks

    0 讨论(0)
  • 2021-02-09 12:06

    See the documentation of the timeZone property of UILocalNotification:

    ... If you assign a valid NSTimeZone object to this property, the fire date is interpreted as a wall-clock time that is automatically adjusted when there are changes in time zones; an example suitable for this case is an an alarm clock.

    So I assume that if you want an absolute time for the notification, you must not assign a time zone.

    0 讨论(0)
提交回复
热议问题