# iOS audio session interruption

**URL:** <https://qa.fmod.com/t/ios-audio-session-interruption/15014>\
**Category:** Unity\
**Created:** [September 3, 2019, 11:56pm UTC](https://qa.fmod.com/t/ios-audio-session-interruption/15014 "2019-09-03T23:56:12Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![wildboystudios](https://avatars.discourse-cdn.com/v4/letter/w/7cd45c/32.png) [@wildboystudios](https://qa.fmod.com/u/wildboystudios)\
**Post date:** [September 3, 2019, 11:56pm UTC](https://qa.fmod.com/t/ios-audio-session-interruption/15014/1 "2019-09-03T23:56:12Z")

</div>

When a timer goes of or a call comes in on iOS, the game automatically mutes, but doesn’t unmute until manually tabbing in and out. I’ve looked at the mixerSuspend and mixerResume functions, and they are being called on OnApplicationPaused already in the FMODRuntimeManager - this should be a very common scenario, do you have any guidelines on how to achieve this in UNITY ? I’ve seen the iOS specific guide but how can I add a listener for the AVAudioSessionInterruptionNotification?  
Neither OnApplicationPause nor OnApplicationFocus are triggered on interruptions…

Thank you!

---

<div class="post-metadata">

**Author:** ![wildboystudios](https://avatars.discourse-cdn.com/v4/letter/w/7cd45c/32.png) [@wildboystudios](https://qa.fmod.com/u/wildboystudios)\
**Post date:** [September 5, 2019, 5:58am UTC](https://qa.fmod.com/t/ios-audio-session-interruption/15014/2 "2019-09-05T05:58:44Z")

</div>

Is there a method I can use to at least perform polling, and check whether the mixer can be resumed ?

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [September 9, 2019, 12:33am UTC](https://qa.fmod.com/t/ios-audio-session-interruption/15014/3 "2019-09-09T00:33:20Z")

</div>

What versions of FMOD and Unity are you using?

---

<div class="post-metadata">

**Author:** ![wildboystudios](https://avatars.discourse-cdn.com/v4/letter/w/7cd45c/32.png) [@wildboystudios](https://qa.fmod.com/u/wildboystudios)\
**Post date:** [September 9, 2019, 1:11am UTC](https://qa.fmod.com/t/ios-audio-session-interruption/15014/4 "2019-09-09T01:11:09Z")

</div>

Unity 2019.2.3 ( also tested in unity 2019.1.8) and FMOD Unity integration V 1.10.15 ( tried 1.10.9 previously ) It is actually only happening for timers/alarms - calls where fine on my last test.  
EDIT: Tested on iOS12 and iOS13 Beta

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [September 9, 2019, 4:58am UTC](https://qa.fmod.com/t/ios-audio-session-interruption/15014/5 "2019-09-09T04:58:17Z")

</div>

I just tested Unity 2019.1.8 using FMOD 1.10.15 and it worked for calls, timers and alarms just fine.

Are you getting anything in the logs? You may need to change the ‘Logging Level’ in the FMOD Unity Settings to `LOG` to get more information.

---

<div class="post-metadata">

**Author:** ![wildboystudios](https://avatars.discourse-cdn.com/v4/letter/w/7cd45c/32.png) [@wildboystudios](https://qa.fmod.com/u/wildboystudios)\
**Post date:** [September 9, 2019, 5:33am UTC](https://qa.fmod.com/t/ios-audio-session-interruption/15014/6 "2019-09-09T05:33:28Z")

</div>

I’m not getting anything in the logs. I had mine set to Warning, I will change it and test again. Does it fire OnApplicationFocus for you when alarm pop up comes in ? Is that supposed to fire?

---

<div class="post-metadata">

**Author:** ![wildboystudios](https://avatars.discourse-cdn.com/v4/letter/w/7cd45c/32.png) [@wildboystudios](https://qa.fmod.com/u/wildboystudios)\
**Post date:** [September 10, 2019, 2:35am UTC](https://qa.fmod.com/t/ios-audio-session-interruption/15014/7 "2019-09-10T02:35:28Z")

</div>

**FMOD Studio: Device iPhone9,3 classed as MobileHigh**

**FMODUnity.RuntimeUtils:GetCurrentPlatform()**

**FMODUnity.RuntimeManager:Initialize()**

**FMODUnity.RuntimeManager:get\_Instance()**

**FMODUnity.RuntimeManager:get\_StudioSystem()**

**FMODUnity.RuntimeManager:GetBus(String)**

I’m just getting these initialisation logs at start up, and no logs whatsoever after that with logging set to LOG.

What I do is:  
Set Alarm to 10 seconds, go back into the game, swipe the alarm banner away ( don’t click on it ) Audio will stop, no logs.

Currently testing with Unity 2019.2.3, XCode 10.3 and Xcode 11 on iOS 12 and iOS 13, iPhone SE, 2 different iPads and iPhone 7 - Same issues reproducible everywhere for me.

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [September 10, 2019, 4:34am UTC](https://qa.fmod.com/t/ios-audio-session-interruption/15014/8 "2019-09-10T04:34:39Z")

</div>

Ah yes, I was able to reproduce this. I was dismissing the notification differently which was causing the sound to come back.

It looks like what is happen is the OS is muting the game when it gets the notification, but then doesn’t un-mute it when the notification stops. The system does trigger a ‘AVAudioSessionInterruptionNotification’ when the notification starts and finishes but this does not appear to trigger Unity’s `OnApplicationFocus`.

---

<div class="post-metadata">

**Author:** ![wildboystudios](https://avatars.discourse-cdn.com/v4/letter/w/7cd45c/32.png) [@wildboystudios](https://qa.fmod.com/u/wildboystudios)\
**Post date:** [September 10, 2019, 4:46am UTC](https://qa.fmod.com/t/ios-audio-session-interruption/15014/9 "2019-09-10T04:46:16Z")

</div>

Glad you managed to reproduce it, I was about to create an empty project and send that along.  
No way around writing my own native plugin to fix this then? Thank you

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [September 12, 2019, 11:00pm UTC](https://qa.fmod.com/t/ios-audio-session-interruption/15014/10 "2019-09-12T23:00:49Z")

</div>

It seems like it may be a bug in Unity, unless there is another way that they expect you to use the AVAudioSessionInterruptionNotification from C#.

---

<div class="post-metadata">

**Author:** ![wildboystudios](https://avatars.discourse-cdn.com/v4/letter/w/7cd45c/32.png) [@wildboystudios](https://qa.fmod.com/u/wildboystudios)\
**Post date:** [September 16, 2019, 4:03am UTC](https://qa.fmod.com/t/ios-audio-session-interruption/15014/11 "2019-09-16T04:03:34Z")

</div>

Just implemented the plugin, but it still won’t work, the audio doesn’t come back.  
I have an issue on tvOS as well where the audio sporadically just won’t work, and calling mixerResume or unPause won’t have any effect, only way to get the audio back is minimizing and unminimizing the app. ( both for this issue and the tvOS issue)

```
public void AudioInterruptionEvent(string message){
    Debug.Log("AUDIO INTERUPT EVENT, message: "+message);
    if(message == "Began"){
        Debug.Log("FMOD Suspending...");
        FMODUnity.RuntimeManager.PauseAllEvents(true);
        fmodSystem.mixerSuspend();
    }
    if(message == "Finished"){
        FMODUnity.RuntimeManager.PauseAllEvents(false);
        fmodSystem.mixerResume();
    }
}
```

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [September 17, 2019, 4:47am UTC](https://qa.fmod.com/t/ios-audio-session-interruption/15014/12 "2019-09-17T04:47:07Z")

</div>

`mixerResume` won’t do anything if `mixerSuspend` has not been called before hand. Depending on how the app has interrupted it may not be getting suspended. Add some logging to make sure they are being called and in the order they need to be in.

---

<div class="post-metadata">

**Author:** ![wildboystudios](https://avatars.discourse-cdn.com/v4/letter/w/7cd45c/32.png) [@wildboystudios](https://qa.fmod.com/u/wildboystudios)\
**Post date:** [September 17, 2019, 5:02am UTC](https://qa.fmod.com/t/ios-audio-session-interruption/15014/13 "2019-09-17T05:02:07Z")

</div>

Mixer suspend is being called I have the debug.log.  
Fmod logs(appart from the initialzation) won’t work on iOS/tvOS builds, what do I need to do get them to work?

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [September 17, 2019, 5:12am UTC](https://qa.fmod.com/t/ios-audio-session-interruption/15014/14 "2019-09-17T05:12:54Z")

</div>

The FMOD logs should appear in the console, make sure you are using development build and that the logging libs are being used: [https://fmod.com/resources/documentation-unity?version=2.0&page=platform-specifics.html#fmod-libs-on-static-platforms](https://fmod.com/resources/documentation-unity?version=2.0&page=platform-specifics.html#fmod-libs-on-static-platforms). You can also change the logging level in the FMOD settings (`LOG` should provide the most information): [https://fmod.com/resources/documentation-unity?version=2.0&page=settings.html#logging-level](https://fmod.com/resources/documentation-unity?version=2.0&page=settings.html#logging-level).

---

<div class="post-metadata">

**Author:** ![wildboystudios](https://avatars.discourse-cdn.com/v4/letter/w/7cd45c/32.png) [@wildboystudios](https://qa.fmod.com/u/wildboystudios)\
**Post date:** [September 17, 2019, 8:12am UTC](https://qa.fmod.com/t/ios-audio-session-interruption/15014/15 "2019-09-17T08:12:59Z")

</div>

Thanks cameron. I was missing the static lib step.

So calling mixerSuspend on the AudioInterruption event (or anywhere else, I tried calling it sporadically)  
doesn’t create any log or do anything. Pausing all events, effectively pauses all events, but also doesn’t create any log.

I’m using LOG as logging level.

When tabbing in and out however mixerSuspend and mixerResume logs show up correctly. (fired from your RuntimeManager implementation in OnApplicationFocus)

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [September 18, 2019, 4:36am UTC](https://qa.fmod.com/t/ios-audio-session-interruption/15014/16 "2019-09-18T04:36:40Z")

</div>

Is the `fmodSystem` you are using to call `mixerSuspend/Resume` the same system from `FMODUnity.RuntimeManager.CoreSystem` or `FMODUnity.RuntimeManager.StudioSystem.getCoreSystem`.

`mixerSuspend/Resume` will both return an `FMOD.RESULT` that will tell you if they fail for some reason.

---

<div class="post-metadata">

**Author:** ![wildboystudios](https://avatars.discourse-cdn.com/v4/letter/w/7cd45c/32.png) [@wildboystudios](https://qa.fmod.com/u/wildboystudios)\
**Post date:** [September 18, 2019, 9:53am UTC](https://qa.fmod.com/t/ios-audio-session-interruption/15014/17 "2019-09-18T09:53:58Z")

</div>

Native plugin with AVAudioSessionInterruption + marshalling callback does the trick.  
UnitySendMessage is async and might have caused some issues here too.

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [September 18, 2019, 11:18pm UTC](https://qa.fmod.com/t/ios-audio-session-interruption/15014/18 "2019-09-18T23:18:37Z")

</div>

Glad to hear you found a solution.

We will look into adding functionality for handling the AVAudioSessionInterruptions in a future release.

---

<div class="post-metadata">

**Author:** ![nzgreg](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/nzgreg/32/972_2.png) [@nzgreg](https://qa.fmod.com/u/nzgreg)\
**Post date:** [September 19, 2019, 3:33am UTC](https://qa.fmod.com/t/ios-audio-session-interruption/15014/19 "2019-09-19T03:33:34Z")

</div>

hey Cameron,

just thought I’d mention that we’re hoping to see this fix soon too because we’ll probably be affected as well.

---

<div class="post-metadata">

**Author:** ![Skyrise](https://avatars.discourse-cdn.com/v4/letter/s/e95f7d/32.png) [@Skyrise](https://qa.fmod.com/u/Skyrise)\
**Post date:** [January 8, 2020, 1:26pm UTC](https://qa.fmod.com/t/ios-audio-session-interruption/15014/20 "2020-01-08T13:26:19Z")

</div>

Hi,

We’re encountering the same problem, was the bug ever fixed?

Many thanks,  
Mauro

[Next page](https://qa.fmod.com/t/ios-audio-session-interruption/15014.md?page=2)
