UIBackgroundModes audio for outgoing VoIP calls?

We have an app which is using VoIP functionality in order to call restaurants. The app is not able to receive calls, but only make outgoing calls using Twilio. We added the `audio` flag to the `UIBackgroundModes` setting in the Info.plist file, because we assumed that we need to maintain the outgoing call/speakers in case the app goes into the "background".

Now I am thinking that we misunderstood what "background" actually means here. Let me clarify: In case the user presses the home button twice and changes to another app (but our app is still running) we want to keep the call open in case the user started one. This is necessary, because the user might need to look up things to provide in the call. In case the app is explicitely closed (e.g. swiped away after tapping the home button twice), we do NOT want to keep the call running.

My question is if we actually need that audio setting in UIBackgroundModes given the above case?

Answered by DTS Engineer in 251846022

When is an app in the background?

The exact definition of “in the background” is a bit tricky because of things like slide over on iPad. You can get a definitive answer by implementing the

-applicationDidEnterBackground:
and
-applicationWillEnterForeground:
delegate callbacks in your app. If you get the former and haven’t yet received the latter, you’re in the background.

As I mentioned we don't want to keep the audio if the user explicitly closes the app.

Based on your earlier emails I think that by “explicitly closes” you mean that the user has removed (by swiping up) the app from the multitasking UI. That terminates the app regardless of its current state:

  • If the app is not running, there’s nothing to do

  • If the app is suspended in the background, its process is terminated resulting in it being removed from memory

  • If the app is running (in the foreground or the background), it process is terminated

In all cases the app is flagged so that it won’t run again in the background until after the user has explicitly relaunched it.

Share and Enjoy

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

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

In case the user presses the home button twice and changes to another app (but our app is still running) we want to keep the call open in case the user started one.

In this sentence, what does “started one” mean?

Share and Enjoy

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

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

Thank you for the quick reply.


| In this sentence, what does “started one” mean?


... started a call.

In case the user presses the home button twice and changes to another app (but our app is still running) we want to keep the call open in case the user started a call (and is still in the call) before he pressed the home button twice.


Hope that clarifies this a bit better.

If you want to continue doing audio when your app is in the background, you should use the

audio
background mode. VoIP apps usually set this and the
voip
background mode. I don’t think you’ll need the latter because it’s only necessary to receive incoming calls (via VoIP push notifications or the legacy VoIP architecture).

Share and Enjoy

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

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

Thanks, but my question was not about if I want to run the "audio" in the background or not, but rather what background actually means.When is an app in the background? When is it in the foreground?

As I mentioned we don't want to keep the audio if the user explicitly closes the app. But if he switches between current open apps (via the double-tap on home button for example) we do want to keep the audio running. Is this scenario considered background or not?

Accepted Answer

When is an app in the background?

The exact definition of “in the background” is a bit tricky because of things like slide over on iPad. You can get a definitive answer by implementing the

-applicationDidEnterBackground:
and
-applicationWillEnterForeground:
delegate callbacks in your app. If you get the former and haven’t yet received the latter, you’re in the background.

As I mentioned we don't want to keep the audio if the user explicitly closes the app.

Based on your earlier emails I think that by “explicitly closes” you mean that the user has removed (by swiping up) the app from the multitasking UI. That terminates the app regardless of its current state:

  • If the app is not running, there’s nothing to do

  • If the app is suspended in the background, its process is terminated resulting in it being removed from memory

  • If the app is running (in the foreground or the background), it process is terminated

In all cases the app is flagged so that it won’t run again in the background until after the user has explicitly relaunched it.

Share and Enjoy

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

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

Thanks eskimo. That points me in the right direction.

UIBackgroundModes audio for outgoing VoIP calls?
 
 
Q