A mere three months into my adventure with Insight Timer, I wrote this about my early days with a meditation practice: My Boppy is My Zafu, and Other Musings on Starting a Meditation Practice with Little Kids. Back then, as I wrote, I managed to meditate with the timer exactly 34% of my days, with an average session of 5.3 minutes.
The user can select between 2 and 60 minutes on the timer and play, pause, reset the timer. When seconds remaining equals zero the timer ends and a meditation bell sound plays to signal the end of the meditation.
Currently I use the default timer on the iphone when I meditate in the Clock app. If I set this timer for 20 minutes and lock the phone, at the end of the 20 minutes the timer will go off and notify me with whatever sound I selected in "When Timer Ends".
When your application is about to move into the background, calculate a timestamp based on the current time and time left, schedule the notification, and then stop all work in your application related to the countdown (like UI loops or any other in-app work). If the user leaves the app or locks the phone, they will receive a notification at that time to bring them back into the app. When your app moves back into the foreground, update your your based on the current time: if any of their timers expired, show the UI as completed; if not, start a new loop to manage the countdown UI from the current point with the time left.
df19127ead