How to allow other audio sources on an iOS app

Hello there! I have a game that’s been out for some time, but I’ve received many reviews asking for allowing podcasts to play while they play the game. The “Mute other audio sources” option appears to have no effect while using FMOD and I’ve read that you need to set AVAudioSession to ambient to make this happen. The problem right now is I cannot find any sort of step by step instruction on where or how to implement this. Has anyone successfully allowed other sources to play through on an iOS app? If so, I would love to know what code to put where to make this happen!
Thanks!

Seems like the AVAudioSession is the correct answer. It is usually configured in the app delegate. Just look through apple documentation - it is quite extensive and has example code included. While not being a step by step tutorial path, it is a great opportunity to learn an ios app lifecycle and audiosession basics so that further issues are easier to understand and resolve.

AVAudioSession ref:
https://developer.apple.com/documentation/avfoundation/avaudiosession

For a deeper dive learn this guide:
https://developer.apple.com/library/archive/documentation/Audio/Conceptual/AudioSessionProgrammingGuide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40007875

which is a part of AVFoundation:
https://developer.apple.com/library/archive/documentation/AudioVideo/Conceptual/AVFoundationPG/Articles/00_Introduction.html#//apple_ref/doc/uid/TP40010188

1 Like

Thank you Roma.

In case any one else runs into this error in the future, I found a solution that works for me. In the Xcode generated unity project open up the UnityAppController.mm file in the classes folder. From there scroll down to line 143 (might be different when you are reading this), but add the second line below to your code.

AVAudioSession* audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory:AVAudioSessionCategoryAmbient error: nil];
[audioSession setActive: YES error: nil];
1 Like