On a phone, users leave your app all the time during a call: to check a message, look up a document, or lock the screen. Without setup, the OS may pause your app, and the call goes silent. This page shows how to keep a call's audio going when the user switches away from your mobile app.
Words used here:
- Background: your app is still running, but not on screen.
- Audio session: the phone's setting for how your app plays and records sound (for example, "this is a call, use the earpiece").
- Background mode: an iOS setting that tells the OS your app may keep running in the background for a reason, like playing audio.
What happens automatically
The SDK starts an audio session before join() connects, and stops it
on leave() / dispose(). You don't need to do anything in code. You only
need the iOS config change below.
If your app already manages its own audio session, turn this off:
new Livqeno({ manageAudioSession: false }); // your app already owns the audio sessionWhen the app goes to the background:
- The call stays connected. A quick app switch shouldn't kick someone out of a meeting.
- Video stops (the OS pauses the camera) and starts again when the user comes back.
- The SDK tells you about the change, so you can react:
new Livqeno({
onAppStateChange: (state) => {
// 'active' | 'background' — your call, not automatic
},
});Keep audio playing in the background (iOS)
This is a one-time change to your iOS project config, not code. For
audio to keep playing in the background, add the audio background mode to
ios/YourApp/Info.plist:
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
</array>Leave the call when the app goes to the background
Some apps would rather end the call, for example a quick video check-in
that shouldn't keep running in someone's pocket. That's up to you. Use
onAppStateChange with leave():
const livqeno = new Livqeno({
onAppStateChange: (state) => {
if (state === 'background') void livqeno.leave();
},
});What to expect
| App state | Audio | Video | Connection |
|---|---|---|---|
| Foreground | Plays | Plays | Normal |
Background, audio mode added | Plays | Paused (OS pauses the camera) | Stays in the room |
Background, audio mode not added | Stops soon after | Paused | iOS pauses the whole app |
Common problems
| Problem | Cause | Fix |
|---|---|---|
| Audio stops a few seconds after going to the background | UIBackgroundModes: audio is missing. | Add it (see above). |
| Camera doesn't come back right away | Some devices take about a second to give the camera back. | If it never comes back, check for an error event. |
Tips for production
- App Store review may ask why your app needs the
audiobackground mode. Be ready to explain. - Test on a real device: lock the screen and switch apps. A simulator isn't enough.
Related
- Reconnection: how the app state and network recovery work.
- React Native SDK: the full production checklist.