npx expo install @notifee/react-native
Keeping The Call Alive In Background
One of the crucial functionalities of a video or audio calling application is to keep the call alive in the background. On this page, we focus on what must be added to your app to support this. After enabling, the user of your app will notice that the call is kept alive even if the app goes to the background as they will still hear the remote audio streams while the app is kept in the background.
Android Setup
Android 8 and above
Starting in Android 8.0 (API level 26), Android allows activities to launch in picture-in-picture (PiP) mode. This means that we can keep the call alive in the background by opening PiP mode.
Head over to the documentation here on how to picture-in-picture (PiP) mode for Android.
Android 7
There is no support for Picture-in-picture (PiP) mode below Android 8. Hence in those platforms, we use a foreground service to keep the call alive. The SDK will automatically create and manage the foreground service. The only requirement is to install the Notifee
library so that SDK can handle a foreground service. To install the Notifee
library, run the following command in your terminal of choice:
yarn add @notifee/react-native
npx pod-install
Optional: override the default configuration of the foreground service notifications
You can also optionally override the default configuration of the notification used by the SDK. Below we give an example of that:
import { StreamVideoRN } from '@stream-io/video-react-native-sdk';
StreamVideoRN.updateConfig({
foregroundService: {
android: {
// you can edit the title and body of the notification here
notificationTexts: {
title: 'Video call is in progress',
body: 'Tap to return to the call',
},
},
},
});
iOS Setup
The way to keep audio alive in the background is to enable the audio
background mode. When you enable this capability, your app’s audio playback will continue to play when users lock their iOS device or switch to another app. In Xcode: Open the Info.plist
file and add audio
in UIBackgroundModes
. By editing this file with a text editor, you should see:
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
</array>