In-app Chat
SDK Error Codes
On this page

Community Member Management

2026-07-06

Feature Overview

ZIM SDK provides comprehensive Community member management capabilities, supporting the following features:

  • Invite users to join a Community
  • Remove Community members
  • Update member roles
  • Transfer Community ownership
  • Query Community member list
  • Query specified member information
  • Set member mute status
  • Listen for member state and information changes

Prerequisites

  • Please refer to Implement basic message sending and receiving to complete ZIM SDK acquisition, initialization, and user login.
  • Please refer to Authenticate with Token to implement user authentication and login.
  • Community features require ZIM SDK 3.0.0 or later.
  • Community is a premium feature. Please contact ZEGOCLOUD Technical Support for activation before use.
  • The Token generation method for Community features is the same as for other ZIM features, with no additional permission declarations required.

Invite Users to Join a Community

Call the inviteUsersIntoCommunityWithUserIDs API to batch invite users to join a Community. The invitation does not require the other party's consent; invited users directly become Community members. Invited users must already be registered in the system. A single API call can invite up to 100 users to join a Community.

Failed user information will be returned through errorUserList.

NSArray<NSString *> *userIDs = @[@"user_1", @"user_2"];

[zim inviteUsersIntoCommunity:userIDs communityID:communityID callback:^(NSString * _Nonnull communityID, NSArray<ZIMErrorUserInfo *> * _Nonnull errorUserList, ZIMError * _Nonnull errorInfo) {
    if (errorInfo.code == ZIMErrorCodenoneSuccess) {
        // Invitation complete
    }
}];
Error CodeDescriptionRecommended Action
6001004Community does not existConfirm if the communityID is correct
6001005User is not in the CommunityOnly occurs in specific scenarios; confirm user status
6001007Community permission errorConfirm whether the current user has invitation permission

Remove Community Members

Call the kickCommunityMembersByUserIDs API to batch remove specified members from the Community. A single API call can remove up to 100 users from the Community.

Warning

Only the Community owner and admins can call this API.

NSArray<NSString *> *userIDs = @[@"user_1", @"user_2"];

[zim kickCommunityMembers:userIDs communityID:communityID callback:^(NSString * _Nonnull communityID, NSArray<ZIMErrorUserInfo *> * _Nonnull errorUserList, ZIMError * _Nonnull errorInfo) {
    if (errorInfo.code == ZIMErrorCodenoneSuccess) {
        // Removal complete
    }
}];

Update Community Member Role

Call the updateCommunityMemberRole API to modify a specified member's role in the Community, such as setting a regular member as an admin.

Warning

Only the Community owner can call this API. Community roles: 1 for Community owner, 2 for Community admin, 3 for Community regular member.

// ZIMCommunityMemberRoleOwner = Owner(1)
// ZIMCommunityMemberRoleAdmin = Admin(2)
// ZIMCommunityMemberRoleMember = Member(3)
[zim updateCommunityMemberRole:ZIMCommunityMemberRoleAdmin forUserID:@"target_user_id" communityID:communityID callback:^(NSString * _Nonnull communityID, NSString * _Nonnull forUserID, ZIMCommunityMemberRole memberRole, ZIMError * _Nonnull errorInfo) {
    if (errorInfo.code == ZIMErrorCodenoneSuccess) {
        // Role updated successfully
    }
}];

Transfer Community Ownership

Call the transferCommunityOwnerToUserID API to transfer the ownership of the current Community to another member within the Community. After the transfer, the original owner will become a regular member.

Warning

Only the Community owner can call this API.

[zim transferCommunityOwner:@"new_owner_user_id" communityID:communityID callback:^(NSString * _Nonnull communityID, NSString * _Nonnull toUserID, ZIMError * _Nonnull errorInfo) {
    if (errorInfo.code == ZIMErrorCodenoneSuccess) {
        // Transferred successfully
    }
}];

Query Community Member List

Call the queryCommunityMemberListByCommunityID API to retrieve the member list of a specified Community in pages.

Pagination rules are the same as querying the Community list: for the first query, set config.nextFlag to 0, then pass the returned nextFlag to the next request until nextFlag returns 0.

ZIMCommunityMemberListQueryConfig *config = [[ZIMCommunityMemberListQueryConfig alloc] init];
config.nextFlag = 0;

[zim queryCommunityMemberListByCommunityID:communityID count:100 config:config callback:^(NSString * _Nonnull communityID, NSArray<ZIMCommunityMemberInfo *> * _Nonnull memberList, long long nextFlag, ZIMError * _Nonnull errorInfo) {
    if (errorInfo.code == ZIMErrorCodenoneSuccess) {
        // Queried successfully
    }
}];

Query Specified Member Information

Call the queryCommunityMembersByUserIDs API to batch query specified users' member information in the Community, including role, mute status, etc.

NSArray<NSString *> *userIDs = @[@"user_1", @"user_2"];

[zim queryCommunityMembersByUserIDs:userIDs communityID:communityID callback:^(NSString * _Nonnull communityID, NSArray<ZIMCommunityMemberInfo *> * _Nonnull memberList, NSArray<ZIMErrorUserInfo *> * _Nonnull errorUserList, ZIMError * _Nonnull errorInfo) {
    if (errorInfo.code == ZIMErrorCodenoneSuccess) {
        // Queried successfully
    }
}];

Mute Members

Call the muteCommunityMembers API to batch set the mute status of specified members in specified Channels within the Community. Mute configuration is passed through ZIMCommunityMemberMuteConfig.

Configuration FieldDescription
channelIDSpecifies the Channel ID where the mute takes effect. Leave blank to apply to all Channels.
durationMute duration (seconds), range 1-2592001 (approximately 30 days), or -1 for permanent mute.
Warning

Only the Community owner and admins can call this API.

NSArray<NSString *> *userIDs = @[@"user_1", @"user_2"];

ZIMCommunityMemberMuteConfig *config = [[ZIMCommunityMemberMuteConfig alloc] init];
config.duration = 3600;
config.channelID = @"channel_001";

[zim muteCommunityMembers:YES userIDs:userIDs communityID:communityID config:config callback:^(NSString * _Nonnull communityID, NSString * _Nonnull channelID, BOOL isMute, NSArray<ZIMErrorUserInfo *> * _Nonnull errorUserList, ZIMError * _Nonnull errorInfo) {
    if (errorInfo.code == ZIMErrorCodenoneSuccess) {
        // Mute set successfully
    }
}];

Listen for Member Changes

Member State Changes

When members join or leave a Community, the SDK will trigger the communityMemberStateChangedWithResult callback. Use updateInfo.getState() to determine whether a member has entered (ENTERED) or exited (EXITED).

- (void)zim:(ZIM *)zim communityMemberStateChangedWithResult:(ZIMCommunityMemberStateChangedEventResult *)result {
    for (ZIMCommunityMemberStateChangeInfo *updateInfo in result.updateInfoList) {
        if (updateInfo.state == ZIMCommunityMemberChangeStateEntered) {
            // Member joined the Community
        } else if (updateInfo.state == ZIMCommunityMemberChangeStateExited) {
            // Member left the Community
        }
    }
}

Member Information Updates

When a Community member's nickname, role, mute status, or other information changes, the SDK will trigger the communityMemberInfoUpdatedWithResult callback.

- (void)zim:(ZIM *)zim communityMemberInfoUpdatedWithResult:(ZIMCommunityMemberInfoUpdatedEventResult *)result {
    for (ZIMCommunityMemberInfoUpdateInfo *updateInfo in result.updateInfoList) {
        ZIMCommunityMemberInfo *memberInfo = updateInfo.memberInfo;
        // memberInfo.memberRole: member role
        // memberInfo.muteInfo: mute information
        // memberInfo.enterInfo: member join information
    }
}
2026-06-24

Previous

Community management

Next

Channel management