logo
In-app Chat
SDK Error Codes
Powered Byspreading
On this page

Manage group info


ZEGOCLOUD's In-app Chat (the ZIM SDK) provides the capability of group information management, allowing you to get or modify group info, such as group name, nickname in the group, group avatar, group notice, and more.

Warning
  • Before you use this feature, you must join a group first. To join a group, refer to the Chapter Join a group of Manage groups.
  • All in-group members (group owner included) can use this feature.

Get group info

To know the detailed info of the group you joined, call the queryGroupInfo method.

You will receive the group info through the callback ZIMGroupInfoQueriedCallback after the query succeeds.

SampleCode
// Get the group info, such as group name, nicknames, group notice.
zim.queryGroupInfo(group_id, new ZIMGroupInfoQueriedCallback() {
    @Override
    public void onGroupInfoQueried(ZIMGroupInfo groupInfo, ZIMError errorInfo) {
        // Get the result of querying group information through errorInfo.
    }
});
1
Copied!

Modify the group name

To modify the group name after joining a group, call the updateGroupName method.

All group members receive a notification through the callback onGroupNameUpdated after the group name is modified successfully.

SampleCode
// Modify the group name.
// groupName is a string with a maximum of 64 bytes, with no special character restrictions.
zim.updateGroupName("new_group_name", group_id, new ZIMGroupNameUpdatedCallback() {
    @Override
    public void onGroupNameUpdated(ZIMError errorInfo) {
    }
});
1
Copied!

Modify the group avatar

After logging in and joining a group, if a user wants to modify the avatar of the group they have joined, they can do so by calling the updateGroupAvatarUrl interface to modify the group avatar.

After a successful modification, all group members will receive a notification through onGroupAvatarUrlUpdated.

SampleCode
// Group members modify the group avatar.
// The URL can be up to 500 bytes long with no special character restrictions.
String groupAvatarUrl = "";
String groupId = "";
zim.updateGroupAvatarUrl(groupAvatarUrl, groupId, new ZIMGroupAvatarUrlUpdatedCallback() {
            @Override
            public void onGroupAvatarUrlUpdated(String groupID, String groupAvatarUrl, ZIMError errorInfo) {
                
            }
        });
1
Copied!

Modify the group notice

To modify the group notice after joining a group, call the updateGroupNotice method.

All group members receive a notification through the callback onGroupNoticeUpdated when the group notice is modified successfully.

SampleCode
// Modify the group notice.
zim.updateGroupNotice("new_group_notice", group_id, new ZIMGroupNameUpdatedCallback() {
    @Override
    public void onGroupNoticeUpdated(ZIMError errorInfo) {
       // Get the result of querying group information through errorInfo.  
    }
});
1
Copied!

Modify the group alias

Group alias is a personalized nickname set by users for a group chat to distinguish from other group chats. For example, you can set the alias for a work group as "Work Group" and the alias for a family group as "Family Group", which makes it more convenient to identify the group chats.

Note

Group alias is only visible to the user who sets it and does not affect the display of the group name for other group chat members.

After logging in and joining a group, if a user wants to modify the group alias, the user can call the updateGroupAlias interface to modify the group alias. The group alias is only visible to the user themselves, and the alias for the corresponding conversation will be automatically synchronized.

SampleCode
// Modify the group alias
// groupAlias is a string with a maximum of 256 bytes, with no special character restrictions.
String group_alias = "NewAlias";
String group_id = "GroupID";
zim.updateGroupAlias(group_alias, group_id, new ZIMGroupAliasUpdatedCallback() {
    @Override
    public void onGroupAliasUpdated(String groupID, String groupAlias, ZIMError errorInfo) {
        // Get the result of modifying the group alias through errorInfo.code
    }
});
1
Copied!

After the modification is successful, all devices of the user can receive notifications through onGroupAliasUpdated.

SampleCode
// Listen for group alias update notifications
public class SelfEventHandler extends ZIMEventHandler {
    @Override
    public void onGroupAliasUpdated(ZIM zim, String groupAlias, String operatedUserID, String groupID) {
        // Business logic
    }
}
1
Copied!

In addition, the user will also receive the onConversationChanged callback to know when the conversationAlias is updated. For more details, please refer to Get the conversation list - Listen for conversation changes.

Previous

Manage groups

Next

Manage group properties