2

To get the device settings time change notification, i found that we have to use UIApplication.significantTimeChangeNotification notification and func applicationSignificantTimeChange(_ application: UIApplication) delegate method.

But in my case even though if app in background or in killed state, then i have to show local notification to the user saying that device time is changed. Is it possible, Please let me know if we have any solution for this.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Anjaneyulu Battula
  • 1,910
  • 16
  • 33

2 Answers2

2

From Apple Document on applicationSignificantTimeChange

If your app is currently suspended, this message is queued until your app returns to the foreground, at which point it is delivered. If multiple time changes occur, only the most recent one is delivered.

So, it clearly conveys that this will work only when the app is in Foreground. It is not even queued up when the app is not running.

To display any local notifications when the app is not running, it should be scheduled in the past to trigger it in the future. And it is not possible for the app to know about the time change event when it is not running. It looks like you would not be able to achieve what you have asked.

Anand
  • 1,820
  • 2
  • 18
  • 25
  • Okay got it, but after killing the app then if i change device time then if i open the app do i get time change notification ? – Anjaneyulu Battula Apr 29 '19 at 12:49
  • According to Apple document, it is not possible. App will not know anything when it is in terminated mode. If it is background, it is possible. – Anand Apr 29 '19 at 12:50
0

I don't believe it is. iOS cannot deliver notifications to an app that is not running and they don't get queued up anywhere.

One potential workaround for this however could be to take the current UTC value from a trusted, online source and compare it with what the device thinks UTC is and store that offset. Once your app restarts, calculate this offset again and if it's significantly different from the one you stored previously, take the action you'd take in response to the Significant Time Change notification.

Will Jones
  • 1,861
  • 13
  • 24