Create a group
Use createGroup to create a group profile and specify its initial members, administrators, and owner.
Use createGroup() to create a group. Set the group profile in GroupInfo, and pass the initial regular members, administrators, and owner as separate parameters. The success callback returns the complete GroupInfo, including the new group's groupID.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
memberUserIDs | List<String> | No | Initial regular members. Pass an empty list when none are needed. |
adminUserIDs | List<String> | No | Initial administrators. Do not repeat a regular member or the owner. |
info | GroupInfo | Yes | Group profile to create, including the fields required by your product. |
ownerUserID | String | Yes | Group owner. Do not also include this user as a member or administrator. |
GroupInfo info = new GroupInfo();
info.setGroupName("Project discussion");
info.setIntroduction("For project members only");
OpenIMClient.getInstance().groupManager.createGroup(
memberUserIDs, adminUserIDs, info, ownerUserID,
new OnBase<GroupInfo>() {
@Override public void onSuccess(GroupInfo group) { /* group contains the new group profile. */ }
@Override public void onError(int code, String error) { /* code and error describe the failure. */ }
}
);Result
The success callback returns the created GroupInfo. Use its groupID to open the group chat, retrieve the profile, or continue managing members; do not persist a group identifier generated before the request.
A successful callback means this request completed, not that every client has already refreshed its joined-group list. Relevant users may subsequently receive onJoinedGroupAdded; merge that GroupInfo by groupID. See Group overview for the complete listener.
Was this page helpful?