Skip to main content
Version: Next

Screen sharing

Our SDK also allow to stream content of mobile device screen.

Installation

Android

To enable screen sharing on android, you need enable foreground services. Here is instruction on how to enable it.

iOS

To enable screen sharing on iOS, you need to follow the steps below.

Background streaming during screen sharing

If you want to continue screen sharing when the app goes to the background, you need to:

  1. Enable VoIP background mode by setting enableVoIPBackgroundMode: true in the plugin configuration or adding the VoIP background mode to your Info.plist
  2. Use the useCallKitService hook in your component to manage the CallKit session

See the background calls documentation for detailed instructions and code examples.

You need to modify app.json file and add our plugin:

{ "expo": { ... "plugins": [ [ "@fishjam-cloud/react-native-client", { "ios": { "enableScreensharing": true, "enableVoIPBackgroundMode": true }, "android": { "enableForegroundService": true } } ] ] } }
Background streaming during screen sharing

If you want to continue screen sharing when the app goes to the background, you need to:

  1. Enable VoIP background mode by setting enableVoIPBackgroundMode: true in the plugin configuration or adding the VoIP background mode to your Info.plist
  2. Use the useCallKitService hook in your component to manage the CallKit session

See the background calls documentation for detailed instructions and code examples.

Usage

You can use useScreenShare hook to enable screen sharing.

Permissions

Permission request is handled for you as soon as you call toggleScreenShare.

Android Foreground Service

On Android API level >= 24, you must use a foreground service when screen sharing. This will be handled automatically for you. If you'd like to configure service behavior (like notification content, other permissions). Checkout useForegroundService hook.

You can enable/disable screen sharing with toggleScreenShare method. And check current state with isScreenShareOn property.

import React, { useCallback } from "react"; import { Button } from "react-native"; import { useScreenShare } from "@fishjam-cloud/react-native-client"; export function ScreenShareButton() { const { toggleScreenShare, isScreenShareOn } = useScreenShare(); const onPressToggle = useCallback( () => toggleScreenShare(), [toggleScreenShare], ); return ( <Button onPress={onPressToggle} title={`${isScreenShareOn ? "Disable" : "Enable"} screen share`} /> ); }