Skip to content

iOS Screen Sharing

Ben Cherry edited this page Dec 11, 2024 · 5 revisions

LiveKit supports integration with ReplayKit to publish a video track based on your device's screen, even while using other apps.

Quick Setup

  1. Add a new Broadcast Upload Extension to your project.
  2. Create an App Group and add both your new extension and your main app to it.
  3. Have your SampleHandler class extend LKSampleHandler
  4. Add your app group identifier to your Info.plist in both targets under RTCAppGroupIdentifier
  5. Add your extension's bundle identifier to your main app's Info.plist under RTCScreenSharingExtension.

More Details

Add a new Broadcast Extension

Add a Broadcast Upload Extension through File -> New -> Target.

Fill out the required information for your extension and click Finish.

Screen Shot 2022-06-10 at 9 57 09 PM

Setup app groups

Add your extension to an app group by going to your extension's target in the project; in the Signings & Capabilities tab, click the + button in the top left and add App Groups. If you haven't done so already, add App Groups to your main app as well, ensuring that the App Group identifier is the same for both.

Setup SampleHandler

  • import LiveKit then change your SampleHandler class to extend LKSampleHandler instead of RPBroadcastSampleHandler.
  • Clear the body of the SampleHandler class - you typically won't need any overrides at all to use it.
  • Add your app group identifier to your Info.plist in both extension and main app targets under RTCAppGroupIdentifier
  • Add your extension's bundle identifier to your main app's Info.plist under RTCScreenSharingExtension.

The result should look similar to the one in our example.

Your broadcast extension is now ready. Call try await room.localParticipant.set(source: .screenShareVideo, enabled: false, captureOptions: ScreenShareCaptureOptions(useBroadcastExtension: true)) from your main app to turn it on.

Clone this wiki locally