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?
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"