Core features
The Video SDK for iOS provides in-session text chat: users can send public and private messages to everyone or to a specific user, and your app receives a callback as each message arrives. Use the ZoomVideoSDKChatHelper to send messages and implement onChatNewMessageNotify on your ZoomVideoSDKDelegate to receive them.
To transfer files through chat, see Send files in chat. To read message metadata, delete messages, or apply host chat privileges, see Manage chat messages.
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.
Common chat implementations in iOS use
UITableViewto display messages. The following sections focus on the SDK chat API only. See UITableView in iOS for the UI side.
Get the chat helper
To send messages or change privileges, grab the ZoomVideoSDKChatHelper from the SDK singleton. Every chat call hangs off it.
let chatHelper = ZoomVideoSDK.shareInstance()?.getChatHelper()
ZoomVideoSDKChatHelper *chatHelper = [[ZoomVideoSDK shareInstance] getChatHelper];
Send a public message
Before exposing a chat composer in your UI, check that chat is enabled. The host may have disabled it for the session through chat privileges. The send methods return a ZoomVideoSDKError; check it for Errors_Success to confirm the SDK accepted the message.
if let chatHelper = ZoomVideoSDK.shareInstance()?.getChatHelper() {
// Check whether chat is enabled in this session.
if !chatHelper.isChatDisabled() {
let error = chatHelper.sendChat(toAll: message)
if error == .Errors_Success {
// The SDK accepted the message.
}
}
}
ZoomVideoSDKChatHelper *chatHelper = [[ZoomVideoSDK shareInstance] getChatHelper];
// Check whether chat is enabled in this session.
if (chatHelper.IsChatDisabled == NO) {
ZoomVideoSDKError error = [chatHelper SendChatToAll:message];
if (error == Errors_Success) {
// The SDK accepted the message.
}
}
Send a private message
Private messages are also a chat privilege the host can disable, separately from public chat. Check isPrivateChatDisabled before exposing a "send to user" UI.
if let chatHelper = ZoomVideoSDK.shareInstance()?.getChatHelper() {
// Check whether public and private chat are enabled in this session.
if !chatHelper.isChatDisabled(), !chatHelper.isPrivateChatDisabled() {
let error = chatHelper.sendChat(to: user, content: message)
if error == .Errors_Success {
// The SDK accepted the message.
}
}
}
ZoomVideoSDKChatHelper *chatHelper = [[ZoomVideoSDK shareInstance] getChatHelper];
// Check whether public and private chat are enabled in this session.
if (chatHelper.IsChatDisabled == NO && chatHelper.IsPrivateChatDisabled == NO) {
ZoomVideoSDKError error = [chatHelper SendChatToUser:user Content:message];
if (error == Errors_Success) {
// The SDK accepted the message.
}
}
Receive incoming messages
Implement onChatNewMessageNotify on your ZoomVideoSDKDelegate. The callback fires for both messages you receive and messages you send. The chatMessage parameter contains the message content and a ZoomVideoSDKUser for both the sender and recipient.
func onChatNewMessageNotify(_ helper: ZoomVideoSDKChatHelper?, message chatMessage: ZoomVideoSDKChatMessage?) {
if let content = chatMessage?.content, let senderName = chatMessage?.senderUser?.getName() {
print("\\(senderName) sent a message: \\(content)")
}
}
- (void)onChatNewMessageNotify:(ZoomVideoSDKChatHelper *)helper message:(ZoomVideoSDKChatMessage *)chatMessage {
NSString *content = chatMessage.content;
ZoomVideoSDKUser *sender = chatMessage.senderUser;
NSLog(@"%@ sent a message: %@", sender.getUserName, content);
}
For everything else you can read off a ZoomVideoSDKChatMessage (timestamps, recipients, message ID, public-vs-private flag), see Manage chat messages.