Reliable timer regardless of the App state?

After watching wwdc2017/216, I have an idea for an App! An apple pie eating competition training app!


The rules:

- Need to finish an apple pie under 2 minutes

- The most number pies finished wins, the time between each "pie eating session" does not count.


The App:

- When the user starts the timer and put the wrist down.

- 2 minutes from the first action, the user will be notified. No other activities performed.

- Will perform an +1 in the cloud database after 2 minutes, with or without user input.


What I looked into so far


- Frontmost App State (https://developer.apple.com/documentation/watchkit/wkextension)

- Wakes from the background to receive notifications. It seems to be only local notifications.

- Remote notification is a non-starter :/

- NSProcessInfo.performExpiringActivity

- Not enough time and the incorrect purpose for this task.

- Keeping the app running as a workout app for 2 minutes? (SMH)

- Any other suggestions are welcome 🙂


How do I get a reliably timed notification to run custom code without keeping the app active? (Can be short timespan)


Could I achieve this without writing it as a workout app? All I care is the timed session and getting notified at the correct time.

Replies

Amend to the original post,


- Frontmost App State (https://developer.apple.com/documentation/watchkit/wkextension)

- Wakes from the background to receive notifications. It seems to be only local *remote/push* notifications.

Keep the app running as a workout app should work.