I can't have a iOS 10 local notification (UNNotification) fire properly across time zones.
In time zone +10 hours, I want it to fire at 17:00:00, and schedule it.
Later when I look at what notifications are scheduled, I get the next firing date of it, still in time zone +10 hours, it will say 17:00:00.
But when I change time zone to +8 hours on the device, and look at what notifications are scheduled, I get the next firing date of it, and it still says 17:00:00. I would have expected it to fire two hours earlier, at 15:00:00.
How can I make it work like this? I have tried changing the timezone of the calendar used for creating the date components fed to the UNCalendarNotificationTrigger (tried things are: TimeZone.init(identifier: "Somewhere")
, TimeZone.autoupdatingCurrent
, possibly others). But it just won't change, AFAIK I always get the exact same fire date even if I change time zones.
UNMutableNotificationContent
andUNCalendarNotificationTrigger
does not accept timezone. It receives date components such ashour
andminute
, then fires it at local time. This is a new behavior from previous iOS versions, which had atimeZone
field onUILocalNotification
. – ScaffoldCalendar.current.dateComponents([.day,.month,.year,.hour,.minute,.timeZone], from: fireDate)
, but the timeZone seems to be ignored by UserNotifications framework. – Scaffold