Mobile Hook Overrides
The mobile SDK overrides several hooks from @fishjam-cloud/react-client with native-aware implementations. The API signatures are the same — call them as you would on web. The behavioral deltas below cover what changes.
For the call-shape of each hook, read the corresponding reference in
../react-client/. This file is only the mobile-specific notes.
useCamera
Same API as web (../react-client/devices.md). Mobile-specific notes:
- Permissions must be granted first. Call
useCameraPermissions().request()beforeuseInitializeDevices(seepermissions.md). - Prefer
selectCamera(deviceId)to switch cameras. Constraint-based device selection via the provider may behave differently than on web; the hook's imperativeselectCamerais the supported path. (Verify against the override implementation inpackages/mobile-client/src/overrides/hooks.tsfor your SDK version.) - Front vs back camera.
cameraDeviceslists both as separateDeviceItems;selectCamera(deviceId)is the only public path to swap. cameraStreamrenders only viaRTCView(not<video>). Seertcview.md.
useMicrophone
- iOS background audio requires the
audiobackground mode inInfo.plist. The Expo plugin addsaudiowhenios.supportsPictureInPicture: true;ios.enableVoIPBackgroundMode: trueaddsvoip(notaudio);ios.enableScreensharing: trueadds neither. There is no dedicated flag for audio-only persistence — enable PiP support (writesaudioas a side-effect) or addaudiotoUIBackgroundModesmanually in a bare workflow. microphoneStreamis not directly playable the way an HTML<audio>element plays a stream. The SDK handles playback of remote audio internally; for local mic, you typically just visualize the levels, not play it back.
useScreenShare
Mobile-only flow detailed in screen-sharing.md. Key API delta over the web hook:
- Adds
presentBroadcastPicker: () => Promise<void>to the destructure — iOS-only; opens the system Stop sheet for an active broadcast (use instead ofstopStreamingto avoid the error dialog the platform pops on force-close). - On iOS,
startStreaming()internally presents the system broadcast picker — no separate component to mount. - On Android,
startStreamingtriggers the MediaProjection consent prompt and requiresuseForegroundService({ enableScreenSharing: true })to be active. setTracksMiddlewareis supported; theTracksMiddlewareshape is mobile-specific (operates on@fishjam-cloud/react-native-webrtcMediaStreamTracks — seepackages/mobile-client/src/overrides/types.ts).
useCustomSource
- Same
(sourceId)signature. The mobile version acceptsMediaStreamfrom any source that produces native streams (e.g. canvas streams from a React Native canvas library, or custom native sources). - No browser
<canvas>.captureStream()— to produce a custom stream, use a library likereact-native-skiaor a custom native module that exposes aMediaStream.
useInitializeDevices
InitializeDevicesSettingsis{ enableVideo?: boolean; enableAudio?: boolean }. There is noenableSimulcastfield — simulcast is configured at provider level via<FishjamProvider videoConfig={{ sentQualities: [...] | false }}>(oraudioConfig).useCamera()does not expose astartStreamingmethod, so don't try to passStreamConfigthere. The mobile encoder may decline simulcast if hardware doesn't support it.- Calling
useInitializeDevicestriggers OS-level permission prompts if you haven't already requested them. Best practice: request permissions explicitly first, then init.
useLivestreamStreamer
- Same API. The streamer's video / audio inputs are
MediaStreamobjects you destructure from the device hooks:useCamera().cameraStream,useMicrophone().microphoneStream, oruseScreenShare().stream. - iOS background streaming requires CallKit-style background modes or the broadcast-extension flow for screen-share livestreams.
useLivestreamViewer
- Same API. The received
streamis aMediaStreamyou render withRTCView:
<RTCView mediaStream={stream} style={{ flex: 1 }} />- WHEP playback works the same as web — viewer tokens, public livestreams, etc.
usePeers
- Same
PeerWithTracksshape. EachTrack(andRemoteTrack) hasstream: MediaStream | null. - Render with
RTCViewinstead of<video>. Mirror the local peer's camera tile for usability.
useCallKit, useCallKitEvent, useCallKitService
These have no web equivalent — see callkit.md.
useAudioOutput
Mobile-only — see audio-output.md.
useCameraPermissions, useMicrophonePermissions
Mobile-only — see permissions.md. Note the API is [query, request] tuple, unlike the imperative request().status shape some other libraries use.
useForegroundService
Mobile-only (Android-only effective) — see foreground-service.md.
Things the mobile SDK does NOT expose
persistLastDevice— the mobileFishjamProvideromits this prop.fishjamClientoverride — the mobileFishjamProviderconstructs its own client withclientType: 'mobile'and doesn't accept an override.useStatistics,useLocalVAD— not in the public surface on web or mobile.
Sources
packages/mobile-client/src/index.ts(exports + re-exports)packages/mobile-client/src/overrides/hooks.tspackages/mobile-client/src/overrides/types.ts- For each hook's full API: corresponding reference in
../react-client/.