Question

I want to create a Alarm clock app. And as i know for this we have to use NSLocalNotification which play music for 30 second, As apple says sound file must be in Main bundle for Notification. How can i play sound file from Music Library ? Most of alarm app on App store are using Music Library ? Any Help Will be really appreciate...

Was it helpful?

Solution

Having built such an app, the answer is that you can't play from the lib for the notification sound, only if they acknowledge the notification and launch your app.

OTHER TIPS

The alternative way to do a short term or overnight alarm app is to declare your app to be a background aware audio app in UIBackgroundModes, and start playing silence in the app using Audio Queues or the RemoteIO Audio Unit. Then just mix your alarm sound into the silence as PCM samples at the appropriate time. You may have to first convert music from the music library into uncompressed samples using AVFoundation.

This technique will burn the user's battery a lot faster than using Notifications though, and may be disabled if the user uses the music player (etc.) or other audio app, so should not be used for alarms that are critical or a long time away in time.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top