1

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] and repeat = 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] and repeat = 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 ?

iKK
  • 6,394
  • 10
  • 58
  • 131
  • 1
    Can you describe exactly what Alarmy runs in the future and what you mean by "fully closed" – Lou Franco May 20 '20 at 12:09
  • @Lou Franco: I describe it better in the original post. – iKK May 21 '20 at 06:39
  • Does "fully closed" and "closed completely" mean you killed the app by swiping up on it? – Lou Franco May 21 '20 at 11:29
  • @Lou Franco: yes, exactly - swiping up and closing/killing completely – iKK May 22 '20 at 07:02
  • A completely closed app can still have local notifications. I would try a notification extension to see if you can run code when they trigger. Without user interaction with the notification, I know of no way for the app to run any code after it is killed. – Lou Franco May 22 '20 at 19:09
  • Thank you Franco, can you please make an example of such a code-executing notification ? I am only aware of code-execution when user-interaction (i.e. pressing the banner) occurs. Do you have an example ? – iKK May 22 '20 at 22:49
  • https://developer.apple.com/documentation/usernotificationsui/unnotificationcontentextension – Lou Franco May 22 '20 at 23:24

0 Answers0