Share directly to a Zoom Room
The code on this page works with either the default UI or the custom UI.
The SDK lets you share directly to a Zoom Room device through a few method calls.
guard let directShareService = MobileRTC.shared().getDirectShareService() else { return }
if directShareService.canStartDirectShare() {
directShareService.startDirectShare()
}
MobileRTCDirectShareService *directShareService = [[MobileRTC sharedRTC] getDirectShareService];
if (!directShareService) {
return;
}
if ([directShareService canStartDirectShare]) {
[directShareService startDirectShare];
}
Conform to the MobileRTCDirectShareServiceDelegate to receive the direct share status callback.
guard let directShareService = MobileRTC.shared().getDirectShareService() else { return }
directShareService.delegate = self
extension ViewController: MobileRTCDirectShareServiceDelegate {
func onDirectShareStatusUpdate(_ status: MobileRTCDirectShareStatus, handler: MobileRTCDirectShareViaMeetingIDOrPairingCodeHandler?) {
if status == .need_MeetingID_Or_PairingCode {
handler?.try(withMeetingNumber: "MEETING_NUMBER") // Join using meeting_number, OR
handler?.try(withPairingCode: "PAIRING_CODE") // Join using pairing_code
}
}
}
// In your .h file, conform to the ZoomSDKDirectShareHelperDelegate
@interface ViewController : UIViewController <MobileRTCDirectShareServiceDelegate>
// In your .m file, add the required delegate and the onDirectShareStatusUpdate callback available
MobileRTCDirectShareService *directShareService = [[MobileRTC sharedRTC] getDirectShareService];
if (!directShareService) {
return;
}
directShareService.delegate = self;
- (void)onDirectShareStatusUpdate:(MobileRTCDirectShareStatus)status handler:(MobileRTCDirectShareViaMeetingIDOrPairingCodeHandler *)handler {
if (status == MobileRTCDirectShareStatus_Need_MeetingID_Or_PairingCode) {
[handler TryWithMeetingNumber:@"MEETING_NUMBER"]; // Join using meeting_number, OR
[handler TryWithPairingCode:@"PAIRING_CODE"]; // Join using pairing_code
}
}
Before stopping a direct share session, confirm that a share is already in progress.
if directShareService.isDirectShareInProgress() {
directShareService.stopDirectShare()
}
if ([directShareService isDirectShareInProgress]) {
[directShareService stopDirectShare];
}