Limitations on iOS background tasks

alarm

I'm thinking of doing an alarm clock for iPhone with music as alarm sound.
I have also evaluated similar apps.
They all seems to share the same limitation.
If the app is not active when the alarm is triggered music cannot be played.

So the question, is this a limitation in iOS ?

Best Answer

If the app is not the active running app, then, unless it meets strict criteria, it cannot start itself to perform such an action. There are a number of limitations for VOIP apps and music players to allow them to stay running, but in your case what would probably work best is a local notification that uses a custom notification sound. This allows you to register a notification for the time of the alarm which will be triggered regardless, as it will not be your app doing the work, but the OS instead which obviously maintains the notifications daemon at all times. Certainly for a "real" push notification you can then have a custom sound, I recall the demo at the relevant WWDC where an ESPN app used a clip of music from their TV channel as the sound, but I am unsure if you can acheive the same with a local one - I don't see any reason why not. Obviously there will be limits on file size and possibly length also, so a full track of music may not be possible.