# Video SDK UI Toolkit 2.0 for iOS

<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

> Zoom Video SDK UI Toolkit is in a public beta. [Share your feedback](https://zoom.sjc1.qualtrics.com/jfe/form/SV_3NMYztWpWzNVSiG) with us, and leverage the [beta FAQ](#beta-faq) for details.

## Get started

### Prerequisites

-   Use the Xcode version required by the Video SDK or toolkit build you consume.
-   Use the iOS deployment target required by that same build.
-   A trusted backend that returns a session token. Do not generate tokens in client code for production.
-   A (Video SDK developer account)[/docs/video-sdk/developer-accounts/] with credentials.

### Required permissions

Add these capabilities to your app's Xcode project settings.

-   Camera - required for local camera video
-   Microphone - required for local microphone audio
-   Background Modes, with values **Audio, AirPlay, and Picture in Picture** and **Voice over IP** checked - keeps the session and audio active when the app is backgrounded

### Screen share: app group and entitlements

Screen sharing requires an app group shared between your main app and your Broadcast Extension target. Add the App Group capability to both targets in Xcode using the same identifier, then confirm both `.entitlements` files contain the same group:

### Initialize toolkit

Initialize Zoom Video SDK first, then attach the toolkit with `ZMUIToolKitManager.initialize(videoSDK:bundleId:)`. There is no `ZMUIToolkitVideoSDKInitializer` in the current toolkit.

```swift
let sdkInitParams = ZoomVideoSDKInitParams()
sdkInitParams.domain = "zoom.us"
sdkInitParams.enableLog = true
sdkInitParams.logFilePrefix = "myapp"
sdkInitParams.appGroupId = "group.<your-app-group>" // omit if not screen sharing

let error = ZoomVideoSDK.shareInstance()?.initialize(sdkInitParams) ?? .Errors_Internal_Error
guard error == .Errors_Success else { return }

guard let sdk = ZoomVideoSDK.shareInstance() else { return }
_ = ZMUIToolKitManager.initialize(
    videoSDK: sdk,
    bundleId: "com.example.myapp.ScreenShare" // broadcast extension bundle id; pass nil if not sharing
)
```

## Integrate

### Add toolkit to your project

Add the `ZMUIToolkit` Swift package or framework to your target's **Frameworks, Libraries, and Embedded Content** in Xcode.

### Build a join screen

First, collect

-   `sessionName`
-   `userName`
-   token
-   optional `sessionPassword`
-   initial media preferences (`localVideoOn`, connect, mute)

Then join.

```swift
let sessionContext = ZoomVideoSDKSessionContext()
sessionContext.sessionName = sessionName
sessionContext.sessionPassword = sessionPassword
sessionContext.userName = displayName
sessionContext.token = jwtToken // mint server-side

let audioOption = ZoomVideoSDKAudioOptions()
audioOption.connect = true
audioOption.mute = false
sessionContext.audioOption = audioOption

let videoOption = ZoomVideoSDKVideoOptions()
videoOption.localVideoOn = true
videoOption.multitaskingCameraAccessEnabled = true // required for PiP
sessionContext.videoOption = videoOption

let session = ZMUIToolKitManager.videoSDK?.joinSession(sessionContext)
```

### Register for SDK events

Implement the `ZoomVideoSDKDelegate` methods on your session screen and register with `ZMUIToolKitManager.videoSDKDelegate.add(_:)`. Do not use `ZMUIToolkitEventHandler` or `setEventHandler` as those are not the current public API.

```swift
// After initialize, the toolkit owns ZoomVideoSDK.delegate.
// Observe via the fan-out. Do not reassign sdk.delegate.
ZMUIToolKitManager.videoSDKDelegate.add(self)
```

## Sessions

### Join

Use `ZMUIToolKitManager.videoSDK?.joinSession(sessionContext)` with `ZoomVideoSDKSessionContext`. There is no `ZMUIToolkitVideoSDKSessionContext` wrapper in the current toolkit.

Important fields:

-   sessionName, userName, token: required
-   sessionPassword: optional
-   localVideoOn, connect, mute: initial local media behavior

### Leave

```
// Leave self only
ZMUIToolKitManager.leaveSession(end: false)

// End session for all (host only)
ZMUIToolKitManager.leaveSession(end: true)
```

### Session lifecycle callbacks

Implement these `ZoomVideoSDKDelegate` methods. Register with `ZMUIToolKitManager.videoSDKDelegate.add(_:)`.

-   `onSessionJoin()` - session connected, show in-session UI
-   `onSessionLeave(_ reason:)` - session ended/left, navigate back to join screen

Leave reasons come from `ZoomVideoSDKSessionLeaveReason` and can include bySelf, kicked by host, ended by host, or network error.

### Query session state

Read session metadata from the SDK session object.

```swift
ZMUIToolKitManager.videoSDK?.getSession()?.getSessionName()
ZMUIToolKitManager.videoSDK?.getSession()?.getSessionID()
ZMUIToolKitManager.videoSDK?.getSession()?.getSessionHostName()
```

## UI Components

`ZMUIToolkit` includes `UIKit` views for standard in-session controls.

-   `ZMUIToolkitAudioBtnz`
-   `ZMUIToolkitVideoBtn`
-   `ZMUIToolkitSwitchCameraBtn`
-   `ZMUIToolkitShareBtn`
-   `ZMUIToolkitPauseShareBtn`
-   `ZMUIToolkitParticipantsBtn`
-   `ZMUIToolkitMoreBtn` (filter with `ZMUIToolkitMoreMenuItems`)
-   `ZMUIToolkitChatBtn`
-   `ZMUIToolkitLeaveSessionBtn`
-   `ZMUIToolkitVirtualBackgroundBtn`
-   `ZMUIToolkitRootVideoView`

All components are `UIView`/`UIButton` subclasses and can be used directly in `UIKit` or wrapped with `UIViewRepresentable` in `SwiftUI`.

```
struct AudioButtonView: UIViewRepresentable {
func makeUIView(context: Context) -> ZMUIToolkitAudioBtn {
let button = ZMUIToolkitAudioBtn()
button.isUserInteractionEnabled = true
return button
}
func updateUIView(_ uiView: ZMUIToolkitAudioBtn, context: Context) {}
}
```

Integration pattern

1. Create buttons and add `ZMUIToolkitRootVideoView` to your view hierarchy.
1. Toggle visibility based on session state.
1. On `onSessionJoin()`, show the control bar and video canvas.
1. On `onSessionLeave(_ reason:)`, return to the join screen.

### Video

Video behavior is driven by toolkit controls and session state.

Add `ZMUIToolkitRootVideoView` to your view hierarchy - it automatically manages participant tiles, pagination for larger sessions, a floating self-preview, and screen share content.

```
let videoView = ZMUIToolkitRootVideoView()
view.addSubview(videoView)
```

Recommended UX

-   Keep `ZMUIToolkitRootVideoView` visible for the full duration of the session.
-   Default `localVideoOn = true` only if your product allows camera auto-start.
-   Hide the video button until camera permission has been granted.

### Audio

Audio state is managed automatically by `ZMUIToolkitAudioBtn`. It reflects the current mute state and handles join-audio flows.

Recommended UX

-   Use `connect = true` to auto-connect voice on join.
-   Use `mute = true` for a muted-by-default join experience.
-   Ensure `NSMicrophoneUsageDescription` is set in `Info.plist` before the button is tapped.

### Share

Screen sharing on iOS uses `ReplayKit` and requires a **Broadcast Upload Extension** target in your Xcode project. The toolkit provides `ZMUIToolkitShareBtn`, which presents the system broadcast picker - no additional view code is needed.

#### Important! Broadcast Extension is required

For this toolkit, tapping the share button alone does not start screen share.

iOS requires screen capture to run in a separate **Broadcast Upload Extension** process. You must create this extension and wire it to the toolkit. If you skip this setup, screen sharing will not start even if the user taps the button.

#### Start share flow

1. Add a **Broadcast Upload Extension** target to your Xcode project.
2. In the extension's `SampleHandler`, initialize the toolkit's screen share service.

```swift
import ReplayKit
import ZoomVideoSDK

class SampleHandler: RPBroadcastSampleHandler, ZoomVideoSDKScreenShareServiceDelegate {
    var screenShareService: ZoomVideoSDKScreenShareService!

    override init() {
        let params = ZoomVideoSDKScreenShareServiceInitParams()
        params.appGroupId = "group.com.example.myapp" // MUST match main app App Group
        params.isWithDeviceAudio = true
        super.init()
        let service = ZoomVideoSDKScreenShareService(params: params)
        self.screenShareService = service
        self.screenShareService.delegate = self
    }

    override func broadcastStarted(withSetupInfo setupInfo: [String: NSObject]?) {
        screenShareService.broadcastStarted(withSetupInfo: setupInfo)
    }
    override func processSampleBuffer(_ sampleBuffer: CMSampleBuffer, with sampleBufferType: RPSampleBufferType) {
        screenShareService.processSampleBuffer(sampleBuffer, with: sampleBufferType)
    }
}
```

3. Ensure both targets share the same App Group (see Entitlements).
4. Pass the **Broadcast Upload Extension** bundle ID as `bundleId` to `ZMUIToolKitManager.initialize(videoSDK:bundleId:)`. Pass `nil` if the app does not screen-share.

#### Notes

The `appGroupId` on `ZoomVideoSDKInitParams` and `ZoomVideoSDKScreenShareServiceInitParams` must exactly match the **App Group** in both entitlements.

-   The toolkit handles all `ReplayKit` coordination internally.
-   Ensure the **App Group** capability is enabled on both targets in Xcode.

### Participants

Participant features are exposed through `ZMUIToolkitParticipantsBtn`. Tapping it opens a built-in participants panel so you can avoid writing this UI from scratch.

**Core participant events**

-   `onUserJoin(userList)`
-   `onUserLeave(userList)`
-   `onUserNameChanged(userInfo)`
-   `onUserHostChanged(userInfo)`
-   `onUserManagerChanged(userInfo)`

### More menu (`ZMUIToolkitMoreBtn`)

Overflow button. Default `includedItems` is `.all`: chat, virtualBackground, recording, share, settings. **Cancel** is always present. An item appears only if it was included and its live gate passes (VB `isSupported`, recording `canControlRecording`, share `isSharing`). Settings has **My Name**, **Video (PiP)**, and **Statistics**, but no chat-privilege toggle.

For Swift `OptionSet`, combine with array / union. For Objective-C, combine `ZMUIToolkitMoreMenuItem` flags with `|`. The sample omits `.chat` because it already has `ZMUIToolkitChatBtn` on the toolbar.

```swift
let moreButton = ZMUIToolkitMoreBtn()
// Keep a subset:
let moreButton = ZMUIToolkitMoreBtn(includedItems: [.virtualBackground, .settings])
// Omit Chat when ZMUIToolkitChatBtn is on the toolbar:
let moreButton = ZMUIToolkitMoreBtn(includedItems: ZMUIToolkitMoreMenuItems.all.subtracting(.chat))
```

```objectivec
ZMUIToolkitMoreBtn *moreButton = [[ZMUIToolkitMoreBtn alloc] init];
moreButton = [[ZMUIToolkitMoreBtn alloc]
    initWithIncludedItems:(ZMUIToolkitMoreMenuItem.virtualBackground | ZMUIToolkitMoreMenuItem.settings)];
```

When Chat is included, the **More** button shows an unread badge and registers as `ZMChatMessageObserver`. If Chat is omitted, the badge stays hidden. Opening chat from **More** marks messages read.

### Chat (`ZMUIToolkitChatBtn`)

Dedicated chat button with unread badge. Opens the same chat panel as the **More** Chat row. If this button is on the toolbar, pass `includedItems` without `.chat` on **More** so the entry is not duplicated.

        ```swift let chatButton = ZMUIToolkitChatBtn()
        toolbarStackView.addArrangedSubview(chatButton) let moreButton =
        ZMUIToolkitMoreBtn(includedItems:
        ZMUIToolkitMoreMenuItems.all.subtracting(.chat)) ```

### Virtual background (`ZMUIToolkitVirtualBackgroundBtn`)

Opens the VB picker (None / Blur / images). Also reachable from **More** when `.virtualBackground` is included and `ZMVirtualBackgroundManager.shared.isSupported`. The preview can include a private switch-camera control for front or rear.

        ```swift
        let vbButton = ZMUIToolkitVirtualBackgroundBtn()
        toolbarStackView.addArrangedSubview(vbButton)
        ```

### Switch camera (`ZMUIToolkitSwitchCameraBtn`)

Momentary control that switches the local camera. Add it next to the video button. Hide or omit it on single-camera devices as the sample does.

        ```swift
        let switchCameraButton = ZMUIToolkitSwitchCameraBtn()
        toolbarStackView.addArrangedSubview(switchCameraButton)
        ```

### Pause share (`ZMUIToolkitPauseShareBtn`)

Pause or resume while the local user is sharing. The **More** `.share` items call the same `ZMShareManager.shared.pauseShare() / resumeShare()`.

        ```swift
        let pauseShareButton = ZMUIToolkitPauseShareBtn()
        toolbarStackView.addArrangedSubview(pauseShareButton)
        ```

### Recording

Cloud recording start/stop/pause/resume appear on **More** when `.recording` is included and `ZMRecordingManager.shared.canControlRecording`. Start/stop use confirmation alerts. Consent is owned by `ZMRecordingManager` and gated by `ZMUIToolKitManager.cloudRecordingConsentDialogEnabled`.

### Observe SDK events

The toolkit owns `ZoomVideoSDK.delegate` after initialize. Observe via `ZMUIToolKitManager.videoSDKDelegate.add(_:)`. Do not reassign `ZoomVideoSDK.delegate`, and do not use `ZMUIToolkitEventHandler` or `setEventHandler` as those are not the current public API.

### Participants

`ZMUIToolkitParticipantsBtn` opens a searchable participant list and shows a live count badge.

-   A host or a manager can mute another participant, or ask that participant to unmute.
-   The host can make host, make co-host, and remove a participant.
-   The host can rename anyone. Every participant can rename themselves.
-   The host sees **Mute all** and **Ask all** to unmute. Those call `muteAllAudio` and `unmuteAllAudio`.

### Chat recipients

The chat panel sends to Everyone or to one participant. Opening the panel marks messages read. `ZMUIToolkitChatBtn` shows the unread badge. When **Chat** is included on **More**, that button shows the badge too.

### Video surface

`ZMUIToolkitRootVideoView` pages horizontally through the local share panel while you are sharing, remote share pages, and the participant gallery. The page dots are hidden when there is only one page.

-   A floating self-video tile is shown on gallery pages when remote users are present.
-   A top-left REC badge is shown while cloud recording is active or paused.
-   System Picture in Picture is driven by `ZMUIToolkitPiPController`. Settings, then Video, persists **Enable PiP Mode**. Set `videoOption.multitaskingCameraAccessEnabled = true` on join when you want the camera to stay available for PiP.

### Leave

`ZMUIToolkitLeaveSessionBtn` is role-aware.

-   A non-host gets **Leave session**, which calls `leaveSession(false)`.
-   A host with other people in the session - **Leave session** opens **Assign a host**, then leaves. End session for all asks for confirmation, then calls `leaveSession(true)`.
-   A host who is alone - **Leave session** calls `leaveSession(true)` and ends the empty session.

`ZMUIToolKitManager.cloudRecordingConsentDialogEnabled` defaults to true. `ZMRecordingManager` presents the consent UI while that flag is on.

### Localization

Set `ZMUIToolkitStrings.stringsBundle` to your app bundle and add a `ZMUIToolkit.strings` table. When the bundle is `nil`, the toolkit uses its built-in English strings.

### Cleanup

Call `ZMUIToolKitManager.cleanup()` when the toolkit should drop `ZoomVideoSDK.delegate` and stop **Picture in Picture**. Call `initialize(videoSDK:bundleId:)` again before the next toolkit screen.

## Suggested Production Checklist

-   Use backend-issued short-lived tokens
-   Never ship SDK keys or secrets in app code
-   Handle permission denial gracefully (camera/microphone/share)
-   Do not reassign `ZoomVideoSDK.delegate`; observe only via `ZMUIToolKitManager.videoSDKDelegate.add(_:)`
-   Keep join or leave navigation deterministic
-   Validate session input fields before join
-   Confirm `appGroupId` and `bundleId` match exactly between main app and broadcast extension
-   Add `NSCameraUsageDescription` and `NSMicrophoneUsageDescription` to `Info.plist`
