Skip to content

Commit

Permalink
Merge pull request #371 from dyte-io/Screen_Share
Browse files Browse the repository at this point in the history
docs: Fix the documentation of screen share on MobileCore-iOS
  • Loading branch information
kumarSudhir7891 authored Jul 3, 2024
2 parents 34ca0d5 + 85d3088 commit 85244ae
Showing 1 changed file with 24 additions and 47 deletions.
71 changes: 24 additions & 47 deletions docs/ios-core/local-user/screen-share-guide.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.

Expand All @@ -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.

```
<key>RTCAppGroupIdentifier</key>
<string>(name of the group)</string>
<key>RTCScreenSharingExtension</key>
<string>(Bundle Identifier)</string>
```

Add below key inside the Info.plist of the main App.

```
<key>RTCScreenSharingExtension</key>
<string>(Bundle Identifier of the Broadcast upload extension)</string>
```

![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)
Expand Down

0 comments on commit 85244ae

Please sign in to comment.