# Add video capabilities to the Contact Center SDK for iOS Follow these steps to add video. - [Initialize the video service](#initialize-the-video-service) - [Fetch the video service instance](#fetch-the-video-service-instance) - [Show the video view](#show-the-video-view) ## Initialize the video service Create an instance of class `ZoomCCItem` to set the channel to use, chat or video. For video, set the `sdkType` property to `ZoomCCIInterfaceType_Video`. Include the `entryId` from your Zoom Contact Center flow. ```objectivec ZoomCCItem *item = [ZoomCCItem new]; item.sdkType = ZoomCCIInterfaceType_Video; item.entryId = APP_VIDEO_ENTRY_ID; ``` ```swift let item = ZoomCCItem.init() item.sdkType = .video item.entryId = APP_VIDEO_ENTRY_ID ``` ## Fetch the video service instance Fetch the video service instance and set its delegate to receive callbacks from `ZoomCCSDK`. Initialize the service by calling `initializeWithItem:`. The service will connect to the Contact Center server to fetch the video information. ```objectivec id videoService = [[ZoomCCInterface sharedInstance] videoService]; videoService.videoDelegate = self; [videoService initializeWithItem:item]; ``` ```swift let videoService = ZoomCCInterface.sharedInstance().videoService() videoService.videoDelegate = self if (videoService.status == .initial) { videoService.initialize(with: item) } ``` ## Show the video view To show the video view, call the function below. The call back gets the view's instance and displays it. The `videoService` requests to start a video session with the Contact Center server. Once it is ready, the user can join the video session automatically inside the `ZoomCCSDK` inner view. ```objectivec __weak typeof(self) wself = self; [videoService fetchUI:^(UIViewController * _Nonnull viewController) { [wself directShow:viewController]; }]; ``` ```swift videoService.fetchUI { vc in self.navigationController?.pushViewController(vc, animated: true) } ``` ## Forcibly end an active video engagement To forcibly end a video engagement, use the endVideo method. This action closes the video view and releases any associated service instances within the Contact Center SDK. ```objectivec id videoService = [[ZoomCCInterface sharedInstance] videoService]; [videoService endVideo]; ``` ```swift let videoService = ZoomCCInterface.sharedInstance().videoService() videoService.endVideo() ``` ## Callbacks These callbacks are available for both chat and video. - [`error`](#error) - [`engagementStart`](#engagementstart) - [`engagementEnd`](#engagementend) - [`eventChange`](#eventchange) - [`loginStatusChanged`](#loginstatuschanged) - [`unreadMsgCountChanged` (chat only)](#unreadmsgcountchanged-chat-only) ### `error` Sent after a service error. - `service` — the current service. - `error` — the service error code. See [errors](contact-center/errors) for details. - `detail` — the error details. ```objectivec - (void)onService:(id)service error:(NSUInteger)error detail:(NSInteger)detail; ``` ```swift func onService(_ service: ZoomCCService, error: UInt, detail: Int) { } ``` ### `engagementStart` Sent after the service creates an engagement. - `service` — the current service. - `engagementId` — the engagement identifier. ```objectivec - (void)onService:(id)service engagementStart:(NSString*)engagementId; ``` ```swift func onService(_ service: ZoomCCService, engagementStart engagementId: String) { } ``` ### `engagementEnd` Sent after the engagement ends. - `service` — the current service. - `engagementId` — the engagement identifier. ```objectivec - (void)onService:(id)service engagementEnd:(NSString*)engagementId; ``` ```swift func onService(_ service: ZoomCCService, engagementEnd engagementId: String) { } ``` ### `eventChange` Sent when a change has occurred, for example, due to a user action. - `service` — the current service. - `event` — the event that occurred. ```objectivec - (void)onService:(id)service eventChange:(ZoomCCSDKEvent)event; ``` ```swift func onService(_ service: ZoomCCService, eventChange event: ZoomCCSDKEvent) { } ``` ### `loginStatusChanged` Sent when the login status has changed. - `service` — the current service. - `status` — the service status. `ZoomCCSDKStatus_Login` means the logging succeeded. ```objectivec - (void)onService:(id)service loginStatusChanged:(ZoomCCSDKStatus)status; ``` ```swift func onService(_ service: ZoomCCService, loginStatusChanged status: ZoomCCSDKStatus) { } ``` ### `unreadMsgCountChanged` (chat only) Sent when the number of unread messages has changed. Only sent for chat. - `service` — the current service. - `status` — the service status. `ZoomCCSDKStatus_Login` means the logging succeeded. ```objectivec - (void)onChatService:(id)service unreadMsgCountChanged:(NSUInteger)count; ``` ```swift func onChatService(_ service: ZoomCCChatService, unreadMsgCountChanged count: UInt) { } ```