Skip to main content

Manage chat room attributes

Chat rooms enable real-time messaging among multiple users.

This page shows how to use the Chat SDK to manage the attributes of a chat room in your app.

Understand the tech

The Chat SDK provides the ChatManager and ChatRoom classes for chat room management, which allows you to implement the following features:

  • Update the name of a chat room
  • Update the description of a chat room
  • Retrieve the announcements of a chat room
  • Update the announcements of a chat room

Prerequisites

Before proceeding, ensure that you meet the following requirements:

  • You have initialized the Chat SDK. For details, see Get Started with Android.
  • You understand the call frequency limit of the Chat APIs supported by different pricing plans as described in Limitations.
  • You understand the number of chat rooms supported by different pricing plans as described in Pricing Plan Details.

Implementation

This section introduces how to call the APIs provided by the Chat SDK to implement the features listed above.

Retrieve and modify the chat room attributes

All the chat room members can call fetchChatRoomFromServer to retrieve the detailed information of the current chat room, including the subject, annoucenments, description, member type, and admin list. The chat room owner and admin can also set and update the chat room information.


_8
// The chat room member call fetchChatRoomFromServer to get the information of the specified chat room.
_8
ChatRoom chatRoom = ChatClient.getInstance().chatroomManager().fetchChatRoomFromServer(chatRoomId);
_8
_8
// The chat room owner and admin call changeChatRoomSubject to modify the chat room subject.
_8
ChatRoom chatRoom = ChatClient.getInstance().chatroomManager().changeChatRoomSubject(chatRoomId, newSubject);
_8
_8
// The chat room owner and admin call changeChatroomDescription to modify the chat room description.
_8
ChatRoom chatRoom = ChatClient.getInstance().chatroomManager().changeChatroomDescription(chatRoomId, newDescription);

Manage chat room announcements

All the chat room members can retrieve the chat room announcements. The chat room owner and admin can set and update the announcements. Once the announcements are updated, all the chat room members receive the onAnnouncementChanged callback.


_5
// Chat room members can call fetchChatRoomAnnouncement to retrieve the chat room annoucements.
_5
String announcement = ChatClient.getInstance().chatroomManager().fetchChatRoomAnnouncement(chatRoomId);
_5
_5
// The chat room owner and admin can call updateChatRoomAnnouncement to set or update the chat room announcements.
_5
ChatClient.getInstance().chatroomManager().updateChatRoomAnnouncement(chatRoomId, announcement);

Listen for chat room events

For details, see Chat Room Events.

Page Content