Chat

Chat is is designed to support in-session text communication. Zoom truncates messages exceeding a binary size of 10,000 bytes. As a best practice, we recommend a limit of 1000 characters per message.

While in a session, users can send chat messages to each other.

The following two main components within the SDK will help you implement in-session messaging features:

  • An instance of ZoomVideoSDKChatHelper provides methods to send and receive messages in a session running on your app.
  • The onChatNewMessageNotify callback from your ZoomVideoSDKDelegate confirms the delivery of a message.

Common chat implementations in iOS use UITableViews. This documentation only goes over how to get information from the ZoomVideoSDK chat API. If you would like to use this API in a UITableView, see UITableViews in iOS.

Send chat messages

Users can send a message privately to a single user or publicly to all users present in a session.

Send a private chat message

// Get the ZoomVideoSDKChatHelper to perform chat actions.
if let chatHelper = ZoomVideoSDK.shareInstance()?.getChatHelper() {
    // Check if chat is enabled in this session.
    if !chatHelper.isChatDisabled(), !chatHelper.isPrivateChatDisabled() {
        // Send message to User.
        chatHelper.sendChat(to: user, content: message)
    }
}
// Get the ZoomVideoSDKChatHelper to perform chat actions.
ZoomVideoSDKChatHelper *chatHelper = [[ZoomVideoSDK shareInstance] getChatHelper];
// Check if chat is enabled in this session.
if (chatHelper.IsChatDisabled == NO && chatHelper.IsPrivateChatDisabled == NO) {
    // Send message to User.
    [chatHelper SendChatToUser:user Content:message];
}

Send a public chat message

// Get the ZoomVideoSDKChatHelper to perform chat actions.
if let chatHelper = ZoomVideoSDK.shareInstance()?.getChatHelper() {
    // Check if chat is enabled in this session.
    if !chatHelper.isChatDisabled() {
        // Send message to all users in this session.
        chatHelper.sendChat(toAll: message)
    }
}
// Get the ZoomVideoSDKChatHelper to perform chat actions.
ZoomVideoSDKChatHelper *chatHelper = [[ZoomVideoSDK shareInstance] getChatHelper];
// Check if chat is enabled in this session.
if (chatHelper.IsChatDisabled == NO) {
    // Send message to all users in this session.
    [chatHelper SendChatToAll:message];
}

Receive chat messages

Use the onChatNewMessageNotify callback to be notified of a new message. The parameter chatMessage contains information about the message including a ZoomVideoSDKUserInfo object for both the sender and recipient.

func onChatNewMessageNotify(_ helper: ZoomVideoSDKChatHelper?, message chatMessage: ZoomVideoSDKChatMessage?) {
    // Use helper to perform chat actions.
    // Message contains the info about a chat message.
    if let content = chatMessage?.content, let senderName = chatMessage?.senderUser?.getName() {
        print("\\(senderName) sent a message: \\(content)")
    }
}
- (void)onChatNewMessageNotify:(ZoomVideoSDKChatHelper *)helper message:(ZoomVideoSDKChatMessage *)chatMessage {
    // Use helper to perform chat actions.
    // Message contains the info about a chat message.
    NSString *content = chatMessage.content;
    ZoomVideoSDKUser *sender = chatMessage.senderUser;
    NSLog(@"%@ sent a message: %@", sender.getUserName, content);
}

For more information on how to use the ZoomVideoSDKUserInfo object, see Sessions.

Chat message details

Here are some additional considerations to make note of while using ZoomVideoSDKChatMessage:

let isChatToAll = chatMessage.isChatToAll // Returns false for private messages.
let currentUserIsSender = chatMessage.isSelfSend // Returns true if the current user sent the message.
let timeMessageWasSent = chatMessage.timeStamp // The time at which the message was sent.
let recipient = chatMessage.receiverUser // The recipient of a private message.
[chatMessage isChatToAll]; // Returns false for private messages.
[chatMessage isSelfSend]; // Returns true if the current user sent the message.
[chatMessage timeStamp]; // The time at which the message was sent.
[chatMessage receiverUser]; // The recipient of a private message.

Callbacks

The following is an example of a chat callback.

Get notified when a message is delivered

func onChatNewMessageNotify(_ helper: ZoomVideoSDKChatHelper?, message chatMessage: ZoomVideoSDKChatMessage?) {
    // Use helper to perform chat actions.
    // Message contains the info about a chat message.
    if let content = chatMessage?.content, let senderName = chatMessage.senderUser?.getName() {
        print("\\(senderName) sent a message: \(content)")
    }
}
- (void)onChatNewMessageNotify:(ZoomVideoSDKChatHelper *)helper message:(ZoomVideoSDKChatMessage *)chatMessage {
    // Use helper to perform chat actions.
    // Message contains the info about a chat message.
    NSString *content = chatMessage.content;
    ZoomVideoSDKUser *sender = chatMessage.senderUser;
    NSLog(@"%@ sent a message: %@", sender.getUserName, content);
}

Send files in chat

Users can transfer files in chat during the session.

Zoom deletes files sent via in-session chat when the session ends.

Enable send files via in-session chat in your Video SDK account portal settings and configure the following settings.

  • Only allow specified file types - Select to allow only specific file types and enter the file extensions in the text box, separated by commas.
  • Maximum file size - Select to limit the file size to 2048 MB.

Check if the file transfer feature is enabled.

if let isFileTransferEnable = ZoomVideoSDK.shareInstance()?.getSession()?.isFileTransferEnable(), isFileTransferEnable {
    // File Transfer is enabled.
}

Get the list of allowed file types that you can transfer.

if let fileType = ZoomVideoSDK.shareInstance()?.getSession()?.getTransferFileTypeWhiteList() {
    // fileType consists of the string value of the allowed file types, multiple values are separated by comma. Exe files are by default forbidden from being transferred.
}

Get the maximum file size to transfer.

if let maxSize = ZoomVideoSDK.shareInstance()?.getSession()?.getMaxTransferFileSize() {
    // fileType consists of the long value of the max allowed file size
}

Send files to all users in the current session.

if let session = ZoomVideoSDK.shareInstance()?.getSession() {
    let error = session.transferFile("filePath")
    if error == .Errors_Success {
        // Transfer successfully
    } else {
        // Failed to transfer
    }
}

Send files to a certain user in the session.

// Get the user you want to send file to
let userToReceiveFile: ZoomVideoSDKUser
let error = userToReceiveFile.transferFile("filePath")
if error == .Errors_Success {
    // Transfer successfully
} else {
    // Failed to transfer
}

Cancel sending files.

// onSendFileStatus under ZoomVideoSDKDelegate
func onSendFileStatus(_ file: ZoomVideoSDKSendFile?, status: ZoomVideoSDKFileTransferStatus) {
    if status != .FileTransferState_TransferDone, let sendingFile = file {
        let error = sendingFile.cancelSend()
    }
}

Start receiving files.

// onReceiveFileStatus under ZoomVideoSDKDelegate
func onReceiveFileStatus(_ file: ZoomVideoSDKReceiveFile?, status: ZoomVideoSDKFileTransferStatus) {
    guard let receiveFile = file else { return }
    let error = receiveFile.startReceive(filePath)
}

Cancel receiving files.

// onReceiveFileStatus under ZoomVideoSDKDelegate
func onReceiveFileStatus(_ file: ZoomVideoSDKReceiveFile?, status: ZoomVideoSDKFileTransferStatus) {
    guard let receiveFile = file else { return }
    let error = receiveFile.cancelReceive()
}

File transfer callbacks

Be sure that you have set up a delegate for callback events to receive file transfer callbacks.

Get notified when you transfer a file.

func onSendFileStatus(_ file: ZoomVideoSDKSendFile?, status: ZoomVideoSDKFileTransferStatus) {
}

Get notified when you receive a file from other users.

func onReceiveFileStatus(_ file: ZoomVideoSDKReceiveFile?, status: ZoomVideoSDKFileTransferStatus) {
}