Core features
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. Two main components within the SDK help you implement in-session messaging:
- An instance of
ZMVideoSDKChatHelperprovides methods to send and receive messages in a session. - The
onChatNewMessageNotifycallback from yourZMVideoSDKDelegateconfirms the delivery of a message.
For sending files and tracking transfer status, see Send files in chat. For per-message metadata, see Chat message details.
Send a private message
Users can send a message privately to a single user.
// Get the ZMVideoSDKChatHelper to perform chat actions.
if let chatHelper = ZMVideoSDK.shared()?.getChatHelper() {
// Check if chat is enabled in this session.
if chatHelper.isChatDisabled() == false, chatHelper.isPrivateChatDisabled() == false {
// Send message to user.
chatHelper.sendChat(to: user, content: message)
}
}
// Get the ZMVideoSDKChatHelper to perform chat actions.
ZMVideoSDKChatHelper *chatHelper = [[ZMVideoSDK sharedVideoSDK] 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 message
Users can send a message publicly to all users in the session.
// Get the ZMVideoSDKChatHelper to perform chat actions.
if let chatHelper = ZMVideoSDK.shared()?.getChatHelper() {
// Check if chat is enabled in this session.
if chatHelper.isChatDisabled() == false {
// Send message to all users in this session.
chatHelper.sendChat(toAll: message)
}
}
// Get the ZMVideoSDKChatHelper to perform chat actions.
ZMVideoSDKChatHelper *chatHelper = [[ZMVideoSDK sharedVideoSDK] 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 incoming messages
To be notified when a message is received, use onChatNewMessageNotify within ZMVideoSDKDelegate. The chatMessage parameter contains information about the message, including a ZMVideoSDKUser info object for both the sender and recipient (if applicable).
func onChatNewMessageNotify(_ helper: ZMVideoSDKChatHelper!, message chatMessage: ZMVideoSDKChatMessage!) {
// Message contains the info about a chat message.
if let content = chatMessage.content, let senderName = chatMessage.sendUser.getName() {
print("\(senderName) sent a message: \(content)")
}
}
- (void)onChatNewMessageNotify:(ZMVideoSDKChatHelper *)helper message:(ZMVideoSDKChatMessage *)chatMessage {
// Message contains the info about a chat message.
NSString *content = chatMessage.content;
ZMVideoSDKUser *sender = chatMessage.sendUser;
NSLog(@"%@ sent a message: %@", [sender getName], content);
}
For more information on how to use the ZMVideoSDKUser object, see Sessions.