Audio Alerts in background

So I am working on an app that requires different audio files to be played using an NSTimer every X amount of time. Yes, it needs to play the audio in the background as well, but I have had inconsistent results trying to do so. I have searched the web thoroughly to find a solution to this problem, but I have had no luck.


I have enabled background modes and checked off item 0(audio) and made sure it was in my info.plist. I have set the "App does not run in background" key to NO in the info.plist. In the viewDidLoad method of the VC, I have set the AVAudioCategory to categoryPlayback and set the AVAudioSession to active. I have also moved these lines of code around in different places of the app to look for different results, and the best results I have gotten is that the app will continue to run in the background sometimes and at other times it will suspend.


Through all of my searching, I have seen forums explaining how to play audio in the background. However, I have not found any solutions to playing short audio files in the background intermittently on different scheduled intervals.


I know of at least one app in the App Store that is able to do this, and they use the ducking feature of AVFoundation to duck audio playing in the background(Im not sure if other frameworks are able to duck background audio, such as AudioToolbox, but I would like to have ducking enabled for my app).

If anyone knows of any legal solution for my problem, your assistance would be greatly appreciated.

In general, apps can’t start playing audio in the background. The

audio
background mode was designed to allow apps to continue playing audio that was started in the foreground, which is the standard way to use music player apps and so on. There are some circumstances where this is possible — for example, navigation apps — but those are very tightly controlled.

The only general-purpose mechanism that will do this is local notifications, but these have some limitations that I suspect will make them unsuitable for you (most specifically, they’ll only play sounds that you have baked into your app’s bundle).

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

WWDC runs Mon, 5 Jun through to Fri, 9 Jun. During that time all of DTS will be at the conference, helping folks out face-to-face. http://developer.apple.com/wwdc/

Through my searching in the app store, I have found at least two fitness apps that are able to play audio intermittently in the background. Whether you send them to the background while they are playing audio or when they are silent, they still continue to run and provide audio alerts in the background. This is the functionality that I need to have in my app that is similar to theres. What methods would they use to acheive this considering both were approved for the app store?

What methods would they use to acheive this considering both were approved for the app store?

I really can’t comment on other developer’s apps.

At this point I’m going to cry ‘uncle’ and recommend that you open a DTS tech support incident so that you can talk to our expert on this topic.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

WWDC runs Mon, 5 Jun through to Fri, 9 Jun. During that time all of DTS will be at the conference, helping folks out face-to-face. http://developer.apple.com/wwdc/

Audio Alerts in background
 
 
Q