I am having an issue with the timezone/time change in the app. Apparently, the OS post a notification NSSystemTimeZoneDidChange
even though the time/timezone has not changed on the device, I mean, the user or the OS has not changed the time/timezone at all.
Could it be possible then the OS posted a push notification NSSystemTimeZoneDidChange if the time/timezone has not changed in the device?
I am using this line to observe the post.
NotificationCenter.default.addObserver(self, selector: #selector(timeZoneChanged(_:)), name: NSNotification.Name.NSSystemTimeZoneDidChange, object: nil)
Edit on 20/01/2022
This is the answer I got from Apple support team:
Part of the question I asked:
Could it be possible for the OS posted [this notification] if the time/timezone has not changed in the device?
The answer I got from them:
Absolutely [1]. It's common for a notification like this to be posted redundantly. In some cases it's triggered by a state change you can't see. For example — and I haven't tested this theory, so it's just an example of how this sort of thing can come about — this notification might be posted if the system's giant list of time zone info has changed. So, the time zone state has changed, but it's not something that affects your app.
But in other cases, a notification might be truly redundant (-: iOS is a complex system and in some cases this complex machinery generates redundant notifications, and there's no need to filter them out because…
Your app should respond to such notifications be refetching the info it cares about and updating its state based on that. If this update is expensive, keep your own copy of the previous state, compare the current system state to that, and only do the update if the stuff you care about has actually changed.