# Use in-meeting chat > The code on this page works with either the **default UI** or the **custom UI**. The Meeting SDK lets you use [in-meeting chat](https://support.zoom.com/hc/en/article?id=zm_kb&sysparm_article=KB0064400) to communicate with other participants in the same meeting. Handle chat functionality through the `MobileRTCMeetingService` interface. ```swift guard let meetingService = MobileRTC.shared().getMeetingService() else { return } ``` ```objectivec MobileRTCMeetingService *meetingService = [[MobileRTC sharedRTC] getMeetingService]; if (!meetingService) { return; } ``` ## Understand the chat callbacks For chat related callbacks, conform to and add the delegate `MobileRTCMeetingServiceDelegate`. The callbacks are `onChatMessageNotification`, `onChatMessageEditNotification` and `onChatMsgDeleteNotification`. ## Control chat settings Before you use in-meeting chat, check if the current meeting or webinar supports chat, and then look at which participants or attendees can use chat. ### Chat settings in a meeting In a meeting, use `getAttendeeChatPriviledge`. ```swift if !meetingService.isChatDisabled() { let chatPrivilege = meetingService.getAttendeeChatPriviledge() } ``` ```objectivec if (!meetingService.isChatDisabled) { MobileRTCMeetingChatPriviledgeType chatPrivilege = [meetingService getAttendeeChatPriviledge]; } ``` The `MobileRTCMeetingChatPriviledgeType` uses one of these values. - `MobileRTCMeetingChatPriviledge_No_One` - No participants may use chat. - `MobileRTCMeetingChatPriviledge_Host_Only` - Only the host of the meeting may use chat. - `MobileRTCMeetingChatPriviledge_Everyone_Publicly` - All participants may use chat, but private messages are not allowed. - `MobileRTCMeetingChatPriviledge_Everyone_Publicly_And_Privately` - All participants may use chat to send both private and public messages. - `MobileRTCMeetingChatPriviledge_Unknown` - Meeting chat privilege is not applicable to the current meeting. If the current user is the meeting's host, they can control chat settings by specifying a `MobileRTCMeetingChatPriviledgeType`. ```swift meetingService.changeAttendeeChatPriviledge(.everyone_Publicly_And_Privately) meetingService.changeAttendeeChatPriviledge(.no_One) ``` ```objectivec [meetingService changeAttendeeChatPriviledge:MobileRTCMeetingChatPriviledge_Everyone_Publicly_And_Privately]; [meetingService changeAttendeeChatPriviledge:MobileRTCMeetingChatPriviledge_No_One]; ``` ### Chat settings in a webinar In a webinar, use `webinarAttendeeChatPrivilege`. ```swift let chatPrivilege = meetingService.getWebinarAttendeeChatPrivilege() ``` ```objectivec MobileRTCChatAllowAttendeeChat chatPrivilege = [meetingService getWebinarAttendeeChatPrivilege]; ``` The `MobileRTCChatAllowAttendeeChat` uses one of these values. - `MobileRTCChatAllowAttendeeChat_ChatWithNone` - No attendees may use chat. - `MobileRTCChatAllowAttendeeChat_ChatWithPanelist` - Only panelists may use chat. - `MobileRTCChatAllowAttendeeChat_ChatWithAll` - All panelists and attendees may use chat. Update a webinar's chat settings by setting a `MobileRTCWebinarPanelistChatPrivilege`. ```swift meetingService.allowAttendeeChat(.chatWithAll) meetingService.allowAttendeeChat(.chatWithPanelist) ``` ```objectivec [meetingService allowAttendeeChat:MobileRTCChatAllowAttendeeChat_ChatWithAll]; [meetingService allowAttendeeChat:MobileRTCChatAllowAttendeeChat_ChatWithPanelist]; ``` ## Send messages To send a public message in either a meeting or a webinar, instantiate a `MobileRTCMeetingChatBuilder` and set the content and message type. ```swift guard let chatMessageToAll = MobileRTCMeetingChatBuilder().setContent("Hello World!")?.setMessageType(.to_All)?.build() else { return } meetingService.sendChatMsg(chatMessageToAll) ``` ```objectivec MobileRTCMeetingChat *chatMessageToAll = [[[[[MobileRTCMeetingChatBuilder alloc] init] setContent:@"Hello World!"] setMessageType:MobileRTCChatMessageType_To_All] build]; if (!chatMessageToAll) { return; } [meetingService sendChatMsg:chatMessageToAll]; ``` For private messages, change the message type to `MobileRTCChatMessageType_To_Individual` and include a receiver ID to specify the message recipient. ```swift guard let chatMessagePrivate = MobileRTCMeetingChatBuilder().setContent("Hello World!")?.setMessageType(.to_Individual)?.setReceiver(123456789)?.build() else { return } meetingService.sendChatMsg(chatMessagePrivate) ``` ```objectivec MobileRTCMeetingChat *chatMessagePrivate = [[[[[[MobileRTCMeetingChatBuilder alloc] init] setContent:@"Hello World!"] setMessageType:MobileRTCChatMessageType_To_Individual] setReceiver:123456789] build]; if (!chatMessagePrivate) { return; } [meetingService sendChatMsg:chatMessagePrivate]; ``` To reply to an existing message in a thread, first get a `threadId` for the message being responded to. For more information on how to get the `threadId`, see [Receive messages](#receive-messages). Once you've retrieved the thread ID, pass it in and set the type based on whether the parent message is public or private. ```swift guard let chatMessagePrivate = MobileRTCMeetingChatBuilder().setContent("Hello World!")?.setMessageType(.to_Individual)?.setReceiver(123456789)?.build() else { return } meetingService.sendChatMsg(chatMessagePrivate) // Reply // 1. Identify the message (MobileRTCMeetingChat) you want to reply to and get its threadID let chatInfo: MobileRTCMeetingChat? = nil guard let chatInfo = chatInfo else { return } let threadID = chatInfo.threadID // 2. Build MobileRTCMeetingChatBuilder with threadID guard let threadReplyMessage = MobileRTCMeetingChatBuilder().setContent("Reply to Hello World!")?.setMessageType(.to_All)?.setThreadId(threadID)?.build() else { return } // 3. Send reply message meetingService.sendChatMsg(chatMessagePrivate) ``` ```objectivec // 1. Identify the message (MobileRTCMeetingChat) you want to reply to and get its threadID MobileRTCMeetingChat *chatInfo = nil; if (!chatInfo) { return; } NSString *threadID = chatInfo.threadID; // 2. Build MobileRTCMeetingChatBuilder with threadID MobileRTCMeetingChat *threadReplyMessage = [[[[[[MobileRTCMeetingChatBuilder alloc] init] setContent:@"Reply to Hello World!"] setMessageType:MobileRTCChatMessageType_To_All] setThreadId:threadID] build]; if (!chatMessagePrivate) { return; } // 3. Send reply message [meetingService sendChatMsg:threadReplyMessage]; ``` Messages sent from the SDK can also include quoted text. The quote position specifies the start and end characters in the quoted text string. ```swift guard let quotedMessage = MobileRTCMeetingChatBuilder().setContent("This is a sample message stylized as a quote")?.setMessageType(.to_All)?.setQuotePosition(0, end: 42)?.build() else { return } meetingService.sendChatMsg(quotedMessage) ``` ```objectivec MobileRTCMeetingChat *quotedMessage = [[[[[[MobileRTCMeetingChatBuilder alloc] init] setContent:@"This is a sample message stylized as a quote"] setMessageType:MobileRTCChatMessageType_To_All] setQuotePosition:0 end:42] build]; if (!chatMessageToAll) { return; } [meetingService sendChatMsg:quotedMessage]; ``` ## Receive messages To display content from chat messages, the SDK provides a callback to get notified of when a new message is sent to the meeting. You can also use this callback to confirm that a message sent by the current user has successfully been posted to the meeting chat. Conform to the `MobileRTCMeetingServiceDelegate` protocol first, then use the `chatInfo` parameter within `onChatMessageNotification` to get information about the chat message. Some data, like `receiverId`, will only be available for specific types of messages. ```swift guard let meetingService = MobileRTC.shared().getMeetingService() else { return } meetingService.delegate = self extension ViewController: MobileRTCMeetingServiceDelegate { func onChatMessageNotification(_ chatInfo: MobileRTCMeetingChat?) { guard let chatInfo = chatInfo else { return } chatInfo.chatId // A unique identifier assigned to this message. chatInfo.content // The content of the message that is visible to users in the meeting. chatInfo.date // The time at which the message was sent. chatInfo.senderId // The Zoom user ID of the user who sent the message. chatInfo.senderName // The display name of the user who sent the message. chatInfo.receiverId // The Zoom user ID of the user on the receiving end of a private message. chatInfo.receiverName // The display name of the user on the receiving end of a private message. chatInfo.isChatToWaitingroom // Whether the message was sent to the waiting room. chatInfo.chatMessageType // The message type, see "MobileRTCChatMessageType". chatInfo.isComment // Whether the chat message is a comment responding to a thread. chatInfo.isThread // Whether the chat message is a thread with comments. chatInfo.threadID // The unique identifier associated with a thread chatInfo.segmentDetails // Get the detailed attributes such as bold, italic, strikethrough and more. } } ``` ```objectivec // In your .h file @interface ViewController : UIViewController { } // In your .m file MobileRTCMeetingService *meetingService = [[MobileRTC sharedRTC] getMeetingService]; if (!meetingService) { return; } meetingService.delegate = self; - (void)onChatMessageNotification:(MobileRTCMeetingChat *)chatInfo { if (!chatInfo) { return; } chatInfo.chatId; // A unique identifier assigned to this message. chatInfo.content; // The content of the message that is visible to users in the meeting. chatInfo.date; // The time at which the message was sent. chatInfo.senderId; // The Zoom user ID of the user who sent the message. chatInfo.senderName; // The display name of the user who sent the message. chatInfo.receiverId; // The Zoom user ID of the user on the receiving end of a private message. chatInfo.receiverName; // The display name of the user on the receiving end of a private message. chatInfo.isChatToWaitingroom; // Whether the message was sent to the waiting room. chatInfo.chatMessageType; // The message type, see "MobileRTCChatMessageType". chatInfo.isComment; // Whether the chat message is a comment responding to a thread. chatInfo.isThread; // Whether the chat message is a thread with comments. chatInfo.threadID; // The unique identifier associated with a thread chatInfo.segmentDetails; // Get the detailed attributes such as bold, italic, strikethrough and more. } ``` ## Delete messages To delete a message sent by the current user, use the `msgId`. This will trigger the `onChatMsgDeleteNotification` callback under the same `MobileRTCMeetingServiceDelegate` ```swift let msgID: String = "" if meetingService.isChatMessageCanBeDeleted(msgID) { meetingService.deleteChatMessage(msgID) } ``` ```objectivec NSString *msgID = @""; if ([meetingService isChatMessageCanBeDeleted:msgID]) { [meetingService deleteChatMessage:msgID]; } ``` ## Parse text format The SDK supports receiving various styles of chat messages such as bold, italic, quote, font color and size, and many more. The styles are included as a list of `MobileRTCSegmentDetails` objects under each of the `MobileRTCMeetingChat` object. ```swift if let chatInfoSegmentDetails = chatInfo.segmentDetails { for segment in chatInfoSegmentDetails { segment.content segment.boldAttrs segment.italicAttrs segment.underlineAttrs // and more } } ``` ```objectivec NSArray *chatInfoSegmentDetails = chatInfo.segmentDetails; if (chatInfoSegmentDetails) { for (MobileRTCSegmentDetails *segment in chatInfoSegmentDetails) { [segment content]; [segment boldAttrs]; [segment italicAttrs]; [segment underlineAttrs]; // and more } } ``` ---