Raven Docs

Background Audio

Keeping a call's audio alive when a mobile app moves to the background — React Native only; not yet on Flutter.

React Native only. @corvidhq/react-native manages an audio session around every call; Flutter has no equivalent yet, and web has no "background" concept in the same sense (a browser tab keeps running audio when unfocused, subject to the OS's own power-management, which Raven doesn't control on any platform).

What happens automatically

Raven starts an audio session before join() connects and stops it on leave()/dispose() — you don't manage this yourself unless you opt out:

new Raven({ manageAudioSession: false }); // your app already owns the audio session

The SDK also watches AppState and reports transitions, but deliberately does not disconnect on background — dropping the socket on a brief app-switch would turn "checked a notification" into "left the meeting." Video capture does stop when backgrounded (the OS suspends the camera) and resumes automatically on return.

new Raven({
  onAppStateChange: (state) => {
    // 'active' | 'background' — your call, not automatic
  },
});

Keeping audio alive in the background (iOS)

Video pausing in the background is normal and unavoidable — but audio continuing (an audio-only call staying live while the user checks another app) needs one thing Raven can't add for you: the audio background mode.

ios/YourApp/Info.plist:

<key>UIBackgroundModes</key>
<array>
  <string>audio</string>
</array>

Without it, iOS suspends the app shortly after backgrounding and the call's audio stops along with everything else — not a Raven bug, a missing platform capability declaration.

Deciding whether to leave instead

Some apps want backgrounding to end the call rather than keep it alive silently. That's a product decision Raven leaves to you — combine onAppStateChange with leave():

const raven = new Raven({
  onAppStateChange: (state) => {
    if (state === 'background') void raven.leave();
  },
});

Expected behavior

App stateAudioVideoReconnect logic
ForegroundLiveLiveNormal
Background, audio mode declaredLivePaused (OS-suspended camera)Unaffected — the room stays joined
Background, audio mode not declaredStops shortly after backgroundingPausedThe app itself gets suspended by iOS, not just the call

Common errors

SymptomWhyFix
Call audio cuts out a few seconds after backgroundingMissing UIBackgroundModes: audio.Add it — see above. There's no code-level workaround.
Camera doesn't resume on foregroundExpected on some devices while the OS finishes reclaiming the camera; usually resolves within a second.If it doesn't recover, check for an unhandled error event rather than assuming it's this.

Production notes

  • Declaring the audio background mode is an App Store review consideration too — be prepared to explain why the app needs it if asked.
  • Don't assume background behavior — test an actual backgrounding scenario (lock the screen, switch apps) on a real device, not just a simulator.