Skip to main content

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 share feature on iOS, you need to follow below steps

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

app.json
{
"expo": {
...
"plugins": {
...
[
"@fishjam-cloud/react-native-client",
{
"ios": {
"enableScreensharing": true
}
}
],
...
}
}
}

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 { 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`}
/>
);
}