Index of every page on this site: llms.txt
All skills
software-mansion-labs avatar

/react-native-client

@43cde80
Run it yourself

React Native / Expo SDK for Fishjam — video/audio streaming on iOS and Android. Use when writing a React Native or Expo app that calls Fishjam, configures the Fishjam Expo plugin, sets up permissions, runs background streaming, integrates CallKit, or renders RTCView. Trigger on: '@fishjam-cloud/react-native-client', 'fishjam expo plugin', 'FishjamProvider mobile', 'useCameraPermissions', 'useMicrophonePermissions', 'useForegroundService', 'useCallKit', 'useCallKitEvent', 'useCallKitService', 'RTCView', 'RTCPIPView', 'ScreenCapturePickerView', 'startPIP', 'stopPIP', 'AudioDeviceType', 'useAudioOutput', '@fishjam-cloud/react-native-webrtc', 'fishjam react native', 'expo fishjam', 'fishjam ios', 'fishjam android', 'broadcast extension'. Re-exports @fishjam-cloud/react-client hooks plus mobile-only: permissions, foreground service, iOS broadcast extension, audio routing, CallKit, Expo config plugin.

  • 11 files
  • 54.9 KB
  • MIT
  • Updated 6 months ago
  • GitHub
Use this Skill: https://skilld.dev/gh/software-mansion-labs/skills/react-native-client

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

screen-sharing.md

≈1.7k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Screen Sharing

Screen sharing in React Native differs significantly between iOS and Android. Both work through the same useScreenShare hook (inherited from ../react-client/), but the native plumbing is platform-specific.

API at the React layer

import { useScreenShare } from '@fishjam-cloud/react-native-client';

const {
  startStreaming,
  stopStreaming,
  stream,
  presentBroadcastPicker, // iOS-only: opens the system Stop sheet for an active broadcast
} = useScreenShare();
const isSharing = stream != null;

useScreenShare extends the web hook (see ../react-client/devices.md) with one extra mobile-only function, presentBroadcastPicker: () => Promise<void>. There's no dedicated isSharing flag — derive it from stream != null (or videoTrack != null).

Android (MediaProjection)

Android plugin config

{
  "android": {
    "enableScreensharing": true,
    "enableForegroundService": true
  }
}

enableForegroundService is required because Android only allows MediaProjection when a foreground service is running. Note that in the current plugin (packages/mobile-client/plugin/src/withFishjamAndroid.ts), the FOREGROUND_SERVICE_* permissions — including FOREGROUND_SERVICE_MEDIA_PROJECTION — are gated by enableForegroundService, not by enableScreensharing. So:

  • Enable both enableScreensharing: true and enableForegroundService: true for Android screen share to work.
  • enableScreensharing adds the MediaProjection service declarations to AndroidManifest.xml.
  • enableForegroundService adds the runtime permissions: FOREGROUND_SERVICE, FOREGROUND_SERVICE_CAMERA, FOREGROUND_SERVICE_MICROPHONE, FOREGROUND_SERVICE_MEDIA_PROJECTION.

Runtime — start the foreground service

import { useForegroundService, useScreenShare } from '@fishjam-cloud/react-native-client';

useForegroundService({
  enableScreenSharing: true,
  enableCamera: true,
  enableMicrophone: true,
  channelId: 'fishjam-channel',
  channelName: 'Fishjam',
  notificationTitle: 'In a call',
  notificationContent: 'You are sharing your screen.',
});

const { startStreaming } = useScreenShare();

<Button title="Share screen" onPress={() => startStreaming()} />

The system shows a consent dialog before capture begins. On user dismissal, startStreaming rejects.

What gets shared on Android

The entire device screen (apps switch, notifications, etc.). Android does not have a per-app or per-window picker like macOS.

iOS (Broadcast Extension)

iOS only allows screen sharing through a separate Broadcast Extension target. The Expo plugin generates this target during prebuild.

iOS plugin config

In your app.json / app.config.js, plugins use a [name, options] tuple form:

{
  "expo": {
    "plugins": [
      ["@fishjam-cloud/react-native-client", {
        "ios": {
          "enableScreensharing": true,
          "broadcastExtensionTargetName": "MyAppScreenSharing",
          "broadcastExtensionDisplayName": "MyApp Screen Sharing",
          "appGroupContainerId": "group.com.myapp.screensharing",
          "mainTargetName": "MyApp"
        }
      }]
    ]
  }
}

appGroupContainerId is optional — it defaults to group.<your-bundle-identifier>. Override it only if you need a custom App Group identifier (e.g. shared with other apps).

After npx expo prebuild, your Xcode project gains a new target with the configured name.

appGroupContainerId pitfall

This is the single most-bitten-by misconfiguration in iOS screen sharing.

  • Both the main app and the broadcast extension must belong to the same App Group.
  • The plugin sets entitlements for the configured appGroupContainerId on both targets.
  • If you regenerate prebuild with a different appGroupContainerId, the extension's entitlements change but cached signing identities can lag — clean Xcode derived data and re-sign.
  • If you manually edit one of the entitlements files (e.g. add a different group), the broadcast extension can't reach the main app's media plumbing and screen sharing silently fails.

Format the value as group.<reverse-dns>.<suffix> and pick something you won't regret — changing it later is painful.

Triggering the iOS picker

On iOS, call startStreaming() — the SDK internally presents the system broadcast picker (BroadcastPickerHelper.presentSystemPickerWithError) and the user picks your extension from the system UI. To stop a live broadcast cleanly, call await presentBroadcastPicker() (returned by useScreenShare()); this opens the system Stop sheet without surfacing the "Screen sharing stopped" error dialog that stopStreaming() triggers.

import { useScreenShare } from '@fishjam-cloud/react-native-client';

const { startStreaming, stopStreaming, presentBroadcastPicker, stream } = useScreenShare();
const isSharing = stream != null;

// Start: system picker pops up automatically.
const onStart = () => startStreaming();

// Stop: open the system Stop sheet (preferred over stopStreaming on iOS).
const onStop = () => presentBroadcastPicker();

What gets shared on iOS

The user's screen across all apps until they tap the stop button (or you call stopStreaming()). iOS doesn't allow restricting to your app's window.

Stopping

stopStreaming();

Tears down both the WebRTC track and the platform-specific capture pipeline. On Android, the foreground service notification updates. On iOS, the system broadcast bar goes away.

Cross-platform UI sketch

import { Platform, Button } from 'react-native';
import {
  useScreenShare,
  useForegroundService,
} from '@fishjam-cloud/react-native-client';

function ScreenShareButton() {
  const { startStreaming, stopStreaming, presentBroadcastPicker, stream } = useScreenShare();
  const isSharing = stream != null;

  useForegroundService({ enableScreenSharing: true });

  const handlePress = () => {
    if (isSharing) {
      // iOS: prefer the system Stop sheet to avoid the "Screen sharing stopped" error dialog.
      if (Platform.OS === 'ios') presentBroadcastPicker();
      else stopStreaming();
      return;
    }
    startStreaming();
  };

  return (
    <Button
      title={isSharing ? 'Stop sharing' : 'Share screen'}
      onPress={handlePress}
    />
  );
}

Sources

  • packages/mobile-client/src/index.ts (re-exports)
  • packages/mobile-client/plugin/src/withFishjamIos.ts (broadcast extension generation)
  • packages/mobile-client/plugin/src/withFishjamAndroid.ts (MediaProjection wiring)
  • https://fishjam.swmansion.com/docs/how-to/client/screensharing
  • Cross-reference: foreground-service.md, picture-in-picture.md

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at 43cde80. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 weeks ago.

Activeupdated 6 months ago

README badge

README badge for software-mansion-labs/skills/react-native-client