AVAudioSession resume

I'm using AVAudioSession in my VOIP app (using also CallKit).
I understand that the session can get interrupted by a number of things, for example by a second incoming call.
Apple states towards the bottom of this page

https://developer.apple.com/library/content/documentation/Audio/Conceptual/AudioSessionProgrammingGuide/HandlingAudioInterruptions/HandlingAudioInterruptions.html#//apple_ref/doc/uid/TP40007875-CH4-SW5
"Note: There is no guarantee that a begin interruption will have a corresponding end interruption. Your app needs to be aware of a switch to a foreground running state or the user pressing a Play button. In either case, determine whether your app should reactivate its audio session."


On the mentioned page there is an example, when the user ignores the incoming call and in that case AVAudioSessionInterruptionTypeEnded is being sent.
But what should I do in every other case, when I don't get an AVAudioSessionInterruptionTypeEnded? (E.g. When the user answers the 2nd call and puts me on hold and later he ends the 2nd call?)


Thanks!

Replies

Hello,


We are also running into the similar problem -


Scenario:

1. User is on CallKit VoIP call using our app.

2. User receives incoming GSM call.

3. CallKit UI is being displayed and user answers the GSM call. The app receives `AVAudioSessionInterruptionTypeBegan`, and the voip call goes on hold.

4. Now user swaps between calls and goes to VoIP call. At this point, our app is not able to play or record audio because it has received `AVAudioSessionInterruptionTypeBegan` on step#3 but it has not received `AVAudioSessionInterruptionTypeEnded` yet. I noticed if I bring the app to the foreground, the app receives `AVAudioSessionInterruptionTypeEnded` but not before that.

Is there a recommendation on how should we handle this scenario.


Thank you,

Piyush

I am running into a similar problem as well. My experience is similar to ptank. If the 3rd party GSM call is ended by the 3rd party, the VOIP call never gets back audio control. It appears as if the native phone app still has control over the audio session. The property AVAudioSession.sharedInstance().isOtherAudioPlaying is true and calling AVAudioSession.sharedInstance().setActive(true) causes an error (NSOSStatusErrorDomain Code=561017449).


There is also a StackOverflow post that details this issue as well:

https://stackoverflow.com/questions/44450640/avaudiosession-did-not-activate-after-a-gsm-call-is-ended-while-having-a-voip-c


It appears that this has been an issue with CallKit for a long time and there is no solution. Does anyone have a workaround for this issue?


Thanks.

Mike

Hi @folcher @ptank is there any solution to the above problem. i am also facing this issue in ios 14. Is there a correct way to activate the audio session after the interruption has ended?

Hello everyone, Same issue. Were you able to find any solution?

Is there any solution to this problem? Could we start a timer to try to resume the Audio Session after our VoIP app return back to the foreground?