Skip to main content

Manage chat group attributes

Chat groups enable real-time messaging among multiple users.

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

Understand the tech

The Chat SDK provides the Group, GroupManager, and GroupChangeListener classes for chat group management, which allows you to implement the following features:

  • Modify the chat group name and description
  • Manage chat group announcements
  • Manage chat group shared files

Prerequisites

Before proceeding, ensure that you meet the following requirements:

  • You have initialized the Chat SDK. For details, SDK quickstart.
  • You understand the call frequency limits of the Chat APIs supported by different pricing plans as described in Limitations.
  • You understand the number of chat groups and chat group members supported by different pricing plans as described in Pricing Plan Details.

Implementation

This section describes how to call the APIs provided by the Chat SDK to implement chat group features.

Modify the chat group name and description

The chat group owner and chat group admins can modify the name and description of the chat group.

Refer to the following sample code to modify the chat group name and description:


_5
// The chat group owner and chat group admins can call changeGroupName to modify the name of the chat group. The name length can be up to 128 characters.
_5
ChatClient.getInstance().groupManager().changeGroupName(groupId,changedGroupName);
_5
_5
// The chat group owner and chat group admins can call changeGroupDescription to modify the description of the chat group. The description length can be up to 512 characters.
_5
ChatClient.getInstance().groupManager().changeGroupDescription(groupId,description);

Manage chat group announcements

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

Refer to the following sample code to manage chat group announcements:


_5
// The chat group owner and chat group admins can call updateGroupAnnouncement to set or update the chat group announcements. The announcement length can be up to 512 characters.
_5
ChatClient.getInstance().groupManager().updateGroupAnnouncement(groupId, announcement);
_5
_5
// All chat group members can call fetchGroupAnnouncement to retrieve the chat group announcements.
_5
ChatClient.getInstance().groupManager().fetchGroupAnnouncement(groupId);

Manage chat group shared files

All chat group members can upload or download group shared files. The chat group owner and chat group admins can delete all of the group shared files, whereas group members can only delete the shared files that they have personally uploaded.

Refer to the following sample code to manage chat group shared files:


_12
// All chat group members can call uploadGroupSharedFile to upload group shared files. The file size can be up to 10 MB.
_12
// Once shared files are uploaded, group members receive the onSharedFileAdded callback.
_12
ChatClient.getInstance().groupManager().uploadGroupSharedFile(groupId, filePath, callBack);
_12
// All chat group members can call asyncDownloadGroupSharedFile to download group shared files.
_12
ChatClient.getInstance().groupManager().asyncDownloadGroupSharedFile(groupId, fileId, savePath, callBack);
_12
_12
// All chat group members can call deleteGroupSharedFile to delete group shared files.
_12
// Once shared files are deleted, chat group members receive the onSharedFileDeleted callback.
_12
ChatClient.getInstance().groupManager().deleteGroupSharedFile(groupId, fileId);
_12
_12
// All chat group members can call fetchGroupSharedFileList to retrieve the list of shared files in the chat group.
_12
ChatClient.getInstance().groupManager().fetchGroupSharedFileList(groupId, pageNum, pageSize);

Listen for chat group events

For details, see [Chat Group Events]./manage-chat-groups#listen-for-chat-group-events).

vundefined