@@ -295,29 +295,7 @@ Enabling screenshare requires extra installation steps:
295
295
296
296
Android screenshare requires a foreground service with type ` mediaProjection ` to be present.
297
297
298
- From 2.4.0 onwards, this is handled internally and no extra setup is required.
299
-
300
- ---
301
-
302
- On versions prior to 2.4.0, you must declare your own foreground service.
303
-
304
- The example app uses [ @supersami/rn-foreground-service ] ( https://github.com/Raja0sama/rn-foreground-service ) for this.
305
-
306
- Add the following permissions to your ` AndroidManifest.xml ` file:
307
-
308
- ``` xml
309
- <uses-permission android : name =" android.permission.FOREGROUND_SERVICE" />
310
- <uses-permission android : name =" android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION" />
311
- ```
312
-
313
- Declare the the service and ensure it's labelled a ` mediaProjection ` service like so:
314
-
315
- ``` xml
316
- <service android : name =" com.supersami.foregroundservice.ForegroundService" android : foregroundServiceType =" mediaProjection" />
317
- <service android : name =" com.supersami.foregroundservice.ForegroundServiceTask" />
318
- ```
319
-
320
- Once setup, start the foreground service prior to using screenshare.
298
+ From version 2.4.0 onwards, this is handled internally and no extra setup is required.
321
299
322
300
### iOS
323
301
@@ -362,6 +340,50 @@ return (
362
340
363
341
You will not be able to publish camera or microphone tracks on iOS Simulator.
364
342
343
+ ## Background Processing
344
+
345
+ ### Android
346
+
347
+ To support staying connected to LiveKit in the background, you will need a foreground service on Android.
348
+
349
+ The example app uses [ @supersami/rn-foreground-service ] ( https://github.com/Raja0sama/rn-foreground-service ) for this.
350
+
351
+ Add the following permissions to your ` AndroidManifest.xml ` file:
352
+
353
+ ``` xml
354
+ <uses-permission android : name =" android.permission.FOREGROUND_SERVICE" />
355
+ <uses-permission android : name =" android.permission.FOREGROUND_SERVICE_CAMERA" />
356
+ <uses-permission android : name =" android.permission.FOREGROUND_SERVICE_MICROPHONE" />
357
+ <uses-permission android : name =" android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
358
+ ```
359
+
360
+ Declare the the service and ensure it's labelled a ` mediaProjection ` service like so:
361
+
362
+ ``` xml
363
+ <service android : name =" com.supersami.foregroundservice.ForegroundService" android : foregroundServiceType =" camera|microphone|mediaPlayback" />
364
+ <service android : name =" com.supersami.foregroundservice.ForegroundServiceTask" />
365
+ ```
366
+
367
+ The camera and microphone permissions/foreground service types can be omitted if you are not using those.
368
+
369
+ Once setup, [ start the foreground service] ( https://github.com/livekit/client-sdk-react-native/blob/main/example/src/callservice/CallService.android.ts ) to keep the app alive in the background.
370
+
371
+ ### iOS
372
+
373
+ By default, simple background processing can be enabled by selecting the ` audio ` and ` voip `
374
+ [ UIBackgroundModes] ( https://developer.apple.com/documentation/bundleresources/information_property_list/uibackgroundmodes )
375
+ in your XCode project. In your project, select your app target -> Signing & Capabilities -> Add Capability -> Background Modes.
376
+
377
+ These background modes will keep the app alive in the background as long as a mic or audio track is playing.
378
+
379
+ For a more robust background that isn't sensitive to the above conditions, we suggest using
380
+ [ CallKit] ( https://developer.apple.com/documentation/callkit/ ) to maintain the
381
+ connection while in the background. The example uses
382
+ [ react-native-callkeep] ( https://github.com/react-native-webrtc/react-native-callkeep )
383
+ for simple integration with CallKit.
384
+
385
+ Our example code can be found [ here] ( https://github.com/livekit/client-sdk-react-native/blob/main/example/src/callservice/CallService.android.ts ) .
386
+
365
387
## Troubleshooting
366
388
367
389
#### Cannot read properties of undefined (reading 'split')
0 commit comments