Background calls Mobile
This guide is exclusively for Mobile (React Native) applications.
Both Android and iOS support calls running in the background, but they use different approaches:
- Android: Uses foreground services to keep the app active in the background
- iOS: Uses CallKit integration to maintain VoIP calls in the background
Below is configuration required to make it work:
- Expo
- Bare workflow
You need to modify app.json file and add our plugin:
{ "expo": { ... "plugins": { ... [ "@fishjam-cloud/mobile-client", { "android": { "enableForegroundService": true }, "ios": { "enableVoIPBackgroundMode": true } } ], ... } } }
Android Configuration
You need to add the following service to AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> ... <application ...> ... <service android:name="io.fishjam.reactnative.FishjamForegroundService" android:foregroundServiceType="camera|microphone|mediaProjection"/> </application> </manifest>
iOS Configuration
You need to add VoIP background mode in Info.plist:
<key>UIBackgroundModes</key> <array> <string>voip</string> </array>
Usage
- Android
- iOS
You can use useForegroundService hook to handle how foreground service behaves on Android.
If you want to use enableCamera or enableMicrophone,
user must first grant permission for this resource. useForegroundService will check if permission is
granted and only then allow to start a service.
import {useCamera ,useMicrophone } from "@fishjam-cloud/mobile-client"; const {isCameraOn } =useCamera (); const {isMicrophoneOn } =useMicrophone ();
On iOS, background calls are achieved through CallKit integration. To enable background streaming on iOS:
- Enable VoIP background mode by setting
enableVoIPBackgroundMode: truein the plugin configuration or adding the VoIP background mode to yourInfo.plist - The SDK will automatically handle CallKit integration for maintaining background audio/video sessions
CallKit integration is handled automatically by the SDK when VoIP background mode is enabled. The call will appear in the iOS call history and can be managed through the native phone interface.
See Also
For an enhanced user experience when your app is in the background, consider enabling Picture in Picture, which allows users to see video content in a floating window while using other apps.