Reputation: 10329
I have a small application which is much like a clock. It has been working great on IOS3, but now I am updating it to iOS4. What I want to do in iOS4 is to let it play a sound any giving time. For instance, if I set it to play at 4.00 PM I want it to play a sound, a sound from the application not from the OS. This works if the app is launced, but if the user went back to the home screen I want the same to happen.
It is OK if a UIAlertView pops up istead of the application.
How can I do this?
Best regards, Paul Peelen
Upvotes: 1
Views: 1064
Reputation: 70673
Two things you could possibly try under iOS 4.
Local Notifications can pop up an alert and play a short sound.
Another power hungry option is to register as a background music player, and play silence until time for the alarm to go off, then add your chosen sound to the "music" output. This will fail if the user switches to another media player app.
Upvotes: -1
Reputation: 1430
What you want is UIApplication setKeepAliveTimeout:handler:
which let you register a handler that will be called. You can use that to start playing audio. (Of course, compute the timeout when your app goes to background)
EDIT: Use UILocalNotification as andy said.
Upvotes: 0