I’d receive emails from time to time complaining my apps that have no sound. However, its actually caused by the user turing on the Silent Switch…
To enable audio playing even when the user turned on the silent switch. Simply put the following code in your app delegate while its launching.
AVAudioSession *audioSession = [AVAudioSession sharedInstance]; [audioSession setCategory:AVAudioSessionCategoryPlayback error:nil]; [audioSession setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionMixWithOthers error:nil]; [audioSession setActive:YES error:nil];
The AVAudioSessionCategoryPlayback category enable your app to play audio while silent switch is on (and even the screen is locked). AVAudioSessionCategoryOptionMixWithOthers allow your audio to mix with other audio from other apps, and of course, its optional.