Skip to content

Commit 0b27ce4

Browse files
FCE-2747: Improve mobile-sdk docs about CallKit and Screen Sharing (#221)
## Description Improved docs to reflect actual state
1 parent da75f81 commit 0b27ce4

5 files changed

Lines changed: 122 additions & 62 deletions

File tree

docs/how-to/client/background-streaming.mdx

Lines changed: 114 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,28 @@ You need to modify `app.json` file and add our plugin:
5353

5454
**Android Configuration**
5555

56-
You need to add the following service to `AndroidManifest.xml`:
56+
Add the following permissions and services to `AndroidManifest.xml`:
5757

5858
```xml title='AndroidManifest.xml'
5959
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
6060
...
61+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
62+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CAMERA"/>
63+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE"/>
64+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION"/>
6165
<application ...>
6266
...
63-
<service android:name="io.fishjam.reactnative.FishjamForegroundService" android:foregroundServiceType="camera|microphone|mediaProjection"/>
67+
<service
68+
android:name="com.oney.WebRTCModule.foregroundService.WebRTCForegroundService"
69+
android:foregroundServiceType="camera|microphone"
70+
android:stopWithTask="true"
71+
/>
72+
<!-- Add this service only if you use screen sharing -->
73+
<service
74+
android:name="com.oney.WebRTCModule.MediaProjectionService"
75+
android:foregroundServiceType="mediaProjection"
76+
android:stopWithTask="true"
77+
/>
6478
</application>
6579
</manifest>
6680
```
@@ -96,23 +110,114 @@ granted and only then allow to start a service.
96110
:::
97111

98112
```tsx
99-
import { useCamera, useMicrophone } from "@fishjam-cloud/react-native-client";
113+
import {
114+
useForegroundService,
115+
useCamera,
116+
useMicrophone,
117+
} from "@fishjam-cloud/react-native-client";
100118

101119
const { isCameraOn } = useCamera();
102120
const { isMicrophoneOn } = useMicrophone();
121+
122+
useForegroundService({
123+
// [!code highlight]
124+
channelId: "io.fishjam.example.fishjamchat.foregroundservice.channel",
125+
channelName: "Fishjam Chat Notifications",
126+
notificationTitle: "Your video call is ongoing",
127+
notificationContent: "Tap to return to the call.",
128+
enableCamera: isCameraOn,
129+
enableMicrophone: isMicrophoneOn,
130+
// enableScreenSharing: true,
131+
});
103132
```
104133

105134
</TabItem>
106135
<TabItem value="ios" label="iOS">
107136

108-
On iOS, background calls are achieved through CallKit integration. To enable background streaming on iOS:
137+
On iOS, background calls are achieved through CallKit integration. You can use the CallKit hooks to manage VoIP calls that continue running in the background.
109138

110-
1. Enable VoIP background mode by setting `enableVoIPBackgroundMode: true` in the plugin configuration or adding the VoIP background mode to your `Info.plist`
111-
2. The SDK will automatically handle CallKit integration for maintaining background audio/video sessions
139+
### Manual CallKit Management
112140

113-
:::note
114-
CallKit integration is handled automatically by the SDK when VoIP background mode is enabled. The call will appear in the iOS call history and can be managed through the native phone interface.
115-
:::
141+
Use the [`useCallKit`](../../api/mobile/variables/useCallKit) hook for fine-grained control over CallKit sessions:
142+
143+
```tsx
144+
import { useCallKit } from "@fishjam-cloud/react-native-client";
145+
146+
const { startCallKitSession, endCallKitSession } = useCallKit();
147+
148+
// Start CallKit session when joining a room
149+
const handleJoinRoom = async () => {
150+
await startCallKitSession({
151+
displayName: "John Doe",
152+
isVideo: true,
153+
});
154+
// ... join room logic
155+
};
156+
157+
// End CallKit session when leaving
158+
const handleLeaveRoom = async () => {
159+
await endCallKitSession();
160+
// ... leave room logic
161+
};
162+
```
163+
164+
### Automatic CallKit Management
165+
166+
Use the [`useCallKitService`](../../api/mobile/variables/useCallKitService) hook for automatic session lifecycle management:
167+
168+
```tsx
169+
import React from "react";
170+
import { useCallKitService } from "@fishjam-cloud/react-native-client";
171+
import { View } from "react-native";
172+
173+
function CallScreen({ username }: { username: string }) {
174+
// CallKit session automatically starts when component mounts
175+
// and ends when component unmounts
176+
useCallKitService({
177+
displayName: username,
178+
isVideo: true,
179+
});
180+
181+
return <View>...</View>;
182+
}
183+
```
184+
185+
### Listening to CallKit Events
186+
187+
Use the [`useCallKitEvent`](../../api/mobile/variables/useCallKitEvent) hook to respond to user interactions with the native CallKit interface:
188+
189+
```tsx
190+
import {
191+
useCallKitEvent,
192+
useCamera,
193+
useMicrophone,
194+
useConnection,
195+
} from "@fishjam-cloud/react-native-client";
196+
197+
const { startMicrophone, stopMicrophone } = useMicrophone();
198+
const { leaveRoom } = useConnection();
199+
200+
// Listen for mute toggle from CallKit UI
201+
useCallKitEvent("muted", (isMuted?: boolean) => {
202+
if (isMuted === true) {
203+
stopMicrophone();
204+
} else if (isMuted === false) {
205+
startMicrophone();
206+
}
207+
});
208+
209+
// Listen for hold state changes
210+
useCallKitEvent("held", (isHeld?: boolean) => {
211+
console.log("Call hold state:", isHeld);
212+
// Handle hold state in your app
213+
});
214+
215+
// Listen for call end from CallKit UI
216+
useCallKitEvent("ended", () => {
217+
// Handle call termination
218+
leaveRoom();
219+
});
220+
```
116221

117222
</TabItem>
118223
</Tabs>

docs/how-to/client/connecting.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,4 +170,4 @@ Now that you're connected to a room, you can explore additional features:
170170
- [List Other Peers](./list-other-peers) - Display video from other participants
171171
- [Data Channels](../../explanation/data-channels) - Send and receive arbitrary data between peers (e.g., text chat)
172172
- [Picture in Picture](./picture-in-picture) - Allow users to watch video in a floating window (Mobile)
173-
- [Background Streaming](./background-streaming) - Keep calls active when the app is backgrounded (Mobile)
173+
- [Background Calls](./background-streaming) - Keep calls active when the app is backgrounded (Mobile)

docs/how-to/client/installation.mdx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,11 @@ Your app needs to have permissions configured in order to use the microphone and
8989

9090
### Android
9191

92-
Permissions below are required to stream audio and video with Fishjam on Android.
92+
These permissions are required to stream audio and video with Fishjam on Android:
9393

9494
- `android.permission.CAMERA`
9595
- `android.permission.RECORD_AUDIO`
9696
- `android.permission.MODIFY_AUDIO_SETTINGS`
97-
- `android.permission.ACCESS_NETWORK_STATE`
98-
- `android.permission.ACCESS_WIFI_STATE`
9997

10098
<Tabs groupId="app-type">
10199

@@ -112,9 +110,7 @@ Add required permissions to the `app.json` file.
112110
"permissions": [
113111
"android.permission.CAMERA",
114112
"android.permission.RECORD_AUDIO",
115-
"android.permission.MODIFY_AUDIO_SETTINGS",
116-
"android.permission.ACCESS_NETWORK_STATE",
117-
"android.permission.ACCESS_WIFI_STATE"
113+
"android.permission.MODIFY_AUDIO_SETTINGS"
118114
]
119115
}
120116
}
@@ -131,7 +127,7 @@ Add required permissions to the `AndroidManifest.xml` file.
131127
...
132128
<uses-permission android:name="android.permission.CAMERA"/>
133129
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
134-
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTING"/>
130+
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
135131
...
136132
</manifest>
137133
```

docs/how-to/client/migration-guide.mdx

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
2-
sidebar_position: 0
3-
sidebar_label: "Migration Guide 📱"
2+
sidebar_position: 14
3+
sidebar_label: "0.25.x Migration Guide 📱"
44
---
55

6-
# Migration Guide <span className="badge badge--mobile">Mobile</span>
6+
# 0.25.x Migration Guide <span className="badge badge--mobile">Mobile</span>
77

88
# Upgrading @fishjam-cloud/react-native-client from 0.24 to 0.25
99

@@ -24,9 +24,7 @@ Add the following WebRTC permissions to your Android configuration in `app.json`
2424
"permissions": [
2525
"android.permission.CAMERA",
2626
"android.permission.RECORD_AUDIO",
27-
"android.permission.MODIFY_AUDIO_SETTINGS",
28-
"android.permission.ACCESS_NETWORK_STATE",
29-
"android.permission.ACCESS_WIFI_STATE"
27+
"android.permission.MODIFY_AUDIO_SETTINGS"
3028
]
3129
}
3230
}
@@ -442,34 +440,3 @@ const [micPermission, requestMicPermission] = useMicrophonePermissions();
442440
### After
443441

444442
Permissions are now handled automatically by the SDK. When you call initializeDevices(), the SDK will automatically request camera and microphone permissions if they haven't been granted yet.
445-
446-
### CallKit Hooks
447-
448-
### Before
449-
450-
```tsx
451-
// @noErrors
452-
import {
453-
useCallKit,
454-
useCallKitService,
455-
useCallKitEvent,
456-
} from "@fishjam-cloud/react-native-client";
457-
458-
// Manual CallKit control
459-
const { startCallKitSession, endCallKitSession } = useCallKit();
460-
461-
// Automatic CallKit service
462-
useCallKitService({
463-
displayName: "User Name",
464-
isVideo: true,
465-
});
466-
467-
// CallKit events
468-
useCallKitEvent("muted", (isMuted) => {
469-
// Handle mute event
470-
});
471-
```
472-
473-
### After
474-
475-
CallKit integration is now handled automatically by the SDK when VoIP background mode is enabled. You no longer need to manually manage CallKit sessions.

docs/how-to/client/screensharing.mdx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,6 @@ Configuring screen sharing on iOS is a little complicated.
210210
</TabItem>
211211
</Tabs>
212212

213-
:::tip[Background streaming during screen sharing]
214-
215-
If you want to continue screen sharing when the app goes to the background, you need to enable VoIP background mode by setting `enableVoIPBackgroundMode: true` in the plugin configuration or adding the VoIP background mode to your `Info.plist`.
216-
217-
See the [background calls documentation](./background-streaming) for detailed instructions and code examples.
218-
219-
:::
220-
221213
## Usage
222214

223215
You can use [`useScreenShare`](../../api/mobile/variables/useScreenShare) hook to enable screen sharing.

0 commit comments

Comments
 (0)