Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Fix the documentation of screen share on MobileCore-iOS #371

Merged
merged 2 commits into from
Jul 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading