02 June 2015

#JustFiguredOut: Local Notifications

It is often a problem to notify user about something. But could we be sure if the user sees those notifications? What if users switched time on the device? What if the device is out of battery just in the fire date? Will user be notified?

I was terribly interested in local notifications behaviour in this situations.

Experiment consisted of two parts:

1. Switching time.


  • Schedule bunch of local notifications.
  • Switch time on the device to some time after scheduled notifications' fire date.
Result: If time was switched less then 15- minutes after the fire date, all scheduled notifications are fired immediately. If switch time to 15 minutes after the fire date and more - notifications are never shown (even if you switch time back again and wait until the fire dafe to come).

Inability to fire notification after returning back to normal time comes from system: it drops off notifications' next fire date after the fire date has come and not restores it again.

2. Turning off the device.


  • Schedule bunch of local notifications.
  • Turn off the device.
  • Wait for fire date to pass.
  • Turn on the device.
Result: all scheduled notifications were appeared fired on devices block screen but (as with switching time) only if the device was turned on not more then 15 minutes after the fire date.

So, in iOS 8.3 and earlier (may be in future too) local notifications scheduled in the system are fired all at once as soon as the fire date is passed.

It works if you switch time on the device manually (not so often case) or  the next time the device is turned on if it was off by the fire date (possible case), but just in 15-minutes interval after the fire date.

But! There is one big difference: if a local notification fires as it should, system automatically removes it from scheduledNotifications list. If it's NOT fired as it should - the notification remains in the list with next file date = null.

Consider the results in your development and use local notifications wisely.

No comments:

Post a Comment