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 ZIMGroupInfoQueriedResult after the query succeeds.

SampleCode
// Get the group info, such as group name, nicknames, group notice.
ZIM
    .getInstance()
    .queryGroupInfo('groupID')
    .then((value) {
        //This will be triggered when operation successful. 
    })
    .catchError((onError) {
        //This will be triggered when operation failed.
    });
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.
ZIM
    .getInstance()
    .updateGroupName('groupName', 'groupID')
    .then((value) {
        //This will be triggered when operation successful. 
    })
    .catchError((onError) {
        //This will be triggered when operation failed.
    });
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 onGroupAvatarUrlUpdatedResult.

SampleCode
// Modify group avatar by group members
// groupAvatarUrl is a string with a maximum of 500 bytes, no special character restrictions.
ZIM.getInstance()
  !.updateGroupAvatarUrl('groupAvatarUrl', 'groupID')
   .then((value) => {
       // Triggered when successful
   })
   .catchError((onError) {
       // Triggered when failed
   });
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
    .getInstance()
    .updateGroupNotice('groupNotice', 'groupID')
    .then((value) {
        //This will be triggered when operation successful. 
    })
    .catchError((onError) {
        //This will be triggered when operation failed.
    });
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.

Untitled
// Update the group alias
// groupAlias is a string with a maximum of 256 bytes, with no special character restrictions.
String groupAlias = 'newAlias';
String groupId = 'groupID';
try{
    ZIMGroupAliasUpdatedResult? result = await ZIM.getInstance()?.updateGroupAlias(groupAlias, groupId);
} on PlatformException catch (onError){
    onError.code; // Error code
    onError.message; // Error message
}
1
Copied!

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

Untitled
// Listen to group alias modification notification
ZIMEventHandler.onGroupAliasUpdated = (ZIM zim, String groupAlias, String operatedUserID, String groupID){
    // Your logic
};
1
Copied!

In addition, the user will also receive the conversationChanged 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