diff --git a/docs/ios-core/local-user/screen-share-guide.mdx b/docs/ios-core/local-user/screen-share-guide.mdx index 1a48d55e0..b4bd18505 100644 --- a/docs/ios-core/local-user/screen-share-guide.mdx +++ b/docs/ios-core/local-user/screen-share-guide.mdx @@ -5,7 +5,8 @@ tags: - ios-core --- -This document explains how to setup screen sharing on a iOS App using Dyte SDK +This document explains how to setup screen sharing on a iOS App using Dyte SDK. +To use this feature one should join the meeting with **Presets** in which Screenshare is enabled. :::warning @@ -16,9 +17,10 @@ This guide is being updated, and might not work as expected in its current form ## Overview 1. Add a new Broadcast Upload Extension to your project. -2. Setup app groups -3. Have your SampleHandler class initialize DyteBroadcastHandler and proxy a few methods. -4. Update Info.plist +2. Setup app groups. +3. Download `DyteSampleHandler` class from [Github repo](https://github.com/dyte-io/iOS-ScreenShare) . +4. Have your SampleHandler class inherited from this downloaded class `DyteSampleHandler` . +5. Update Info.plist. ### Add a new Broadcast Upload Extension to your project. @@ -43,67 +45,42 @@ Add your extension to an app group by going to your extension's target in the pr import ReplayKit import DyteiOSCore -class SampleHandler: RPBroadcastSampleHandler { - - let dyteBroadcast: DyteBroadcastHandler = DyteBroadcastHandler(); - - override init() { - super.init() - } - override func broadcastPaused() { - dyteBroadcast.broadcastPaused() - } - - override func broadcastResumed() { - dyteBroadcast.broadcastResumed() - } - - override func broadcastFinished() { - dyteBroadcast.broadcastFinished() - } - - override func broadcastStarted(withSetupInfo setupInfo: [String : NSObject]?) { - dyteBroadcast.broadcastStartedWithSetupInfo(setupInfo: setupInfo) - } - - override func processSampleBuffer(_ sampleBuffer: CMSampleBuffer, with sampleBufferType: RPSampleBufferType) { - let rawPointer = Unmanaged.passUnretained(sampleBuffer).toOpaque() - dyteBroadcast.processSampleBuffer(sampleBuffer: rawPointer, withType: Int64(sampleBufferType.rawValue)) - - } - -} +class SampleHandler: DyteSampleHandler {} ``` ### Modify Info.plist -Make sure **both of them** (App and Extension Info.plist) contains these keys +Make sure **both of them** (App and Extension Info.plist) contains below key. ``` RTCAppGroupIdentifier (name of the group) - RTCScreenSharingExtension - (Bundle Identifier) +``` + +Add below key inside the Info.plist of the main App. + +``` +RTCScreenSharingExtension + (Bundle Identifier of the Broadcast upload extension) ``` ![Info.plist screenshot](/static/mobile/0.x.x/ios-setup-info.png) ### Start the Screenshare -Launch the broadcast extension and call the method `enableScreenshare()` +To Launch the broadcast extension and call the method `enableScreenshare()` ```swift +dyteClient.localUser.enableScreenshare() +``` -let screenShareExtensionId = Bundle.main.infoDictionary?["RTCScreenSharingExtension"] as? String; -let view = RPSystemBroadcastPickerView() -view.preferredExtension = screenShareExtensionId -view.showsMicrophoneButton = false -let selector = NSSelectorFromString("buttonPressed:") -if view.responds(to: selector) { - view.perform(selector, with: nil) -} +### Stop the Screenshare -dyteClient.localUser.enableScreenshare() +To stop the ongoing screenshare and call the method `disableScreenshare()`. This will show the system +alert with a stop button for stopping screen share. + +```swift +dyteClient.localUser.disbaleScreenshare() ``` ![screenshot](/static/mobile/0.x.x/ios-setup-app.png)