Skip to content

Commit cf27048

Browse files
authored
Merge pull request #360 from dyte-io/dyte-io/react-native
docs: added screenshare docs for iOS React Native
2 parents 5184d27 + d8a4346 commit cf27048

File tree

1 file changed

+114
-21
lines changed

1 file changed

+114
-21
lines changed

docs/rn-core/local-user/introduction.mdx

Lines changed: 114 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ tags:
88
- self
99
---
1010

11-
1211
# Introduction
1312

14-
Accessible via `self` key within the `meeting` object, the local user object consists of all the information related to the current participant and methods to configure media and other states.
13+
Accessible via `self` key within the `meeting` object, the local user object consists of all the information related to the current participant and methods to configure media and other states.
1514

1615
## Properties
1716

@@ -46,10 +45,10 @@ Here is a list of properties that local user provides:
4645
- `roomJoined`: A <span className="tag-orange">boolean</span> value indicating if the local user is in the meeting
4746
- `roomState`: Indicates the state of the user in the meeting. It
4847
can take the following values:
49-
50-
```ts
51-
"init" | "joined" | "waitlisted" | "rejected" | "kicked" | "left" | "ended"
52-
```
48+
49+
```ts
50+
'init' | 'joined' | 'waitlisted' | 'rejected' | 'kicked' | 'left' | 'ended';
51+
```
5352

5453
```mermaid
5554
stateDiagram-v2
@@ -70,8 +69,6 @@ stateDiagram-v2
7069

7170
<br />
7271

73-
74-
7572
## Change the name of the local user
7673

7774
Change the user's name by calling `setName` method. The changed name will
@@ -130,19 +127,115 @@ flowchart LR
130127
class eam basic;
131128
```
132129

133-
### Enable / Disable Screen share
134-
135-
```ts
136-
// Enable Screenshare
137-
await meeting.self.enableScreenShare();
138-
139-
// Disable Screenshare
140-
await meeting.self.disableScreenShare();
141-
142-
// Get current status
143-
meeting.self.screenShareEnabled;
144-
```
145-
130+
### Enable / Disable Screenshare
131+
132+
<Tabs
133+
groupId="mobile-pm"
134+
defaultValue="android"
135+
values={[
136+
{ label: "Android", value: "android" },
137+
{ label: "iOS", value: "ios" },
138+
]}
139+
>
140+
<TabItem value="android">
141+
```ts
142+
// Enable Screenshare
143+
await meeting.self.enableScreenShare();
144+
145+
// Disable Screenshare
146+
await meeting.self.disableScreenShare();
147+
148+
// Get current status
149+
meeting.self.screenShareEnabled;
150+
```
151+
152+
</TabItem>
153+
<TabItem value="ios">
154+
- In <code>Xcode</code>, Go to Targets -> Add a target -> Choose <code>Broadcast Upload Extension</code> (Choose Swift as Language)
155+
- Go to <code>Targets Signing & Capabilities</code>, and enable <code>App Groups</code> for both App target and Broadcast Upload Extension target
156+
- In the app's target, add the following in <code>Info.plist</code>:
157+
```
158+
<key>RTCAppGroupIdentifier</key>
159+
<string>YOUR_APP_GROUP</string>
160+
```
161+
- Add these changes to your iOS folder's Podfile:
162+
```ruby
163+
target 'YOUR_APP_TARGET_NAME'
164+
...
165+
166+
post_install do |installer|
167+
...
168+
# Add these for Dyte iOS Screenshare
169+
installer.pods_project.targets.each do |target|
170+
target.build_configurations.each do |config|
171+
config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'No'
172+
config.build_settings['ENABLE_USER_SCRIPT_SANDBOXING'] = 'No'
173+
end
174+
end
175+
...
176+
end
177+
178+
...
179+
end
180+
181+
# Add this at the end of Podfile
182+
pod 'YOUR_BROADCAST_EXTENSION_TARGET_NAME'
183+
config = use_native_modules!
184+
use_react_native!(:path => config["reactNativePath"], :hermes_enabled => false)
185+
# Support ReactNativeCore Pod in the Broadcast Upload Extension
186+
pod 'ReactNativeCore', :path => '../node_modules/@dytesdk/react-native-core'
187+
end
188+
```
189+
- Replace the <code>SampleHandler</code> in Broadcast Upload Extension with the following:
190+
```swift
191+
import ReactNativeCore
192+
193+
class SampleHandler: DyteScreenshareHandler {
194+
override init() {
195+
super.init(appGroupIdentifier: "YOUR_APP_GROUP", bundleIdentifier: "BUNDLE_IDENTIFIER_FOR_BROADCAST_UPLOAD_EXTENSION")
196+
}
197+
}
198+
```
199+
> <b>Note:</b>
200+
Replace <code>YOUR_APP_GROUP</code> with your App Group Name and <code>BUNDLE_IDENTIFIER_FOR_BROADCAST_UPLOAD_EXTENSION</code> with Bundle Identifier of Screnshare Extension.
201+
- Go to Broadcast Extension target -> <code>Build Settings</code>
202+
- <code>Build Options</code> -> Set <code>User Script Sandboxing</code> to <code>No</code>
203+
- <code>Signing</code> -> <code>Enable App Sandbox</code> to <code>No</code>
204+
- Now enable the screenshare pop up handle and then enable Dyte's screenshare API:
205+
```tsx
206+
// Import this component
207+
import { NativeModules, findNodeHandle } from 'react-native';
208+
import { ScreenCapturePickerView } from '@dyteinternals/react-native-webrtc';
209+
210+
function MyComponent() {
211+
212+
const screenCapturePickerViewRef = useRef(null);
213+
214+
// Function to show ScreenCapture Picker
215+
const showScreenRecordPicker = async () => {
216+
const handle = findNodeHandle(screenCapturePickerViewRef.current);
217+
NativeModules.ScreenCapturePickerViewManager.show(handle);
218+
};
219+
220+
// To enable screenshare
221+
await showScreenRecordPicker();
222+
await meeting.self.enableScreenShare();
223+
224+
// To disable screenshare
225+
await meeting.self.disableScreenShare();
226+
227+
return (
228+
...
229+
// Add this in components
230+
<ScreenCapturePickerView ref={screenCapturePickerViewRef} />
231+
...
232+
);
233+
234+
}
235+
```
236+
237+
</TabItem>
238+
</Tabs>
146239
<head>
147240
<title>React Native Core Introduction</title>
148241
</head>

0 commit comments

Comments
 (0)