Using iOS - without any network connection,
The Alarmy App is able to run code at a certain time in the future - even if the App is fully closed.
How do they do that ?
To further explain, here my thoughts about how Alarmy does the endless alarm:
- Alarmy is able to set an alarm anytime in the future.
- the App is closed completely
- when the Alarm moment occurs, then there is some code running that sets a local Notification with a
calendarComponentSet = [.second]
andrepeat = true
(that way the notification repeats every minute endlessly) - it further sets 20 reminder local-Notifications 3 seconds apart from each other, again with a
calendarComponentSet = [.second]
andrepeat = true
(that way the minute is filled with 20 more notifications - you can see that when the Alarmy notifications start and you observe that every 3 seconds the count in the NotificationCenter goes up. The count goes up until 19 - no higher. After that the repeat kicks in, repeating every 20 notifications. The 20-package is repeated every minute endlessly and you can avoid hitting the 64-max Limit of Notifications) - everything works without Internet, nor user-permissions (except notification permissions)
Now the big Question:
HOW CAN YOU CAUSE SOME CODE RUNNING IN YOUR APP AT A PARTICULAR MOMENT IN THE FUTURE WITHOUT THE APP RUNNING ?
This moment is used by some small code that sets up the 20 notifications with repeat. But how can you trigger that code in a fully closed app ? So far, I only saw how a user-interaction on a notification-Banner causes code to execute. But how does it work without the user pressing any banner ?