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 queryGroupInfoByGroupID 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 queryGroupInfoByGroupID:groupID callback:^(ZIMGroupInfo * _Nonnull groupInfo, ZIMError * _Nonnull errorInfo) {
        //Implement the event callback for query the group info, such as group name, nicknames, group notice here. 
}];
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 groupNameUpdated 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:groupName groupID:groupID callback:^(ZIMError * _Nonnull errorInfo) {
        //Implement the event callback for the results of modify the group name here. 
}];
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 groupAvatarUrlUpdated.

SampleCode
// Group members modify the group avatar
// The URL can be up to 500 bytes long with no special character restrictions.
[zim updateGroupAvatarUrl:groupAvatarUrl groupID:groupID callback:^(ZIMError * _Nonnull errorInfo) {
         // Write your business code here after calling the interface to modify the group avatar.
}];
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 groupNoticeUpdated when the group notice is modified successfully.

SampleCode
// Modify the group notice.
[zim updateGroupNotice:groupNotice groupID:groupID callback:^(ZIMError * _Nonnull errorInfo) {
        //Implement the event callback for modifying the group notice here.
}];
1
Copied!
SampleCode
// Modify the group alias
// groupAlias is a string with a maximum of 256 bytes, with no special character restrictions.
NSString *groupAlias = @"NewAlias";
NSString *groupID = @"GroupID";
[zim updateGroupAlias:groupAlias groupID:groupID callback:^(NSString *groupID, NSString *groupAlias, ZIMError *errorInfo) {
        // Write your business logic after calling the method to modify the group alias here
}];
1
Copied!

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

SampleCode
@interface ZIMEventHandlerImpl : NSObject<ZIMEventHandler>

+(ZIMEventHandlerImpl *)getInstance();

@end

@implementation ZIMEventHandlerImpl

// Listen for group alias update notifications
- (void)zim:(ZIM *)zim
    groupAliasUpdated:(NSString *)groupAlias
       operatedUserID:(NSString *)operatedUserID
              groupID:(NSString *)groupID {
    // Business logic
}

// Other callback events...

@end

ZIMEventHandlerImpl *eventHandlerImpl = [ZIMEventHandlerImpl getInstance];

[zim setEventHandler: eventHandlerImpl];
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