SDKsAndroid
Invite users to a group
Use the Android SDK to invite a list of users to a group.
Invite one or more users to join a specified group. The group's join verification policy (configured via Set group join verification) determines the invitation outcome: if the group requires verification, invited users may need administrator approval; if set to direct join or verification-free, users are added immediately.
Code example
String groupID = "group_123";
List<String> inviteeUserIDs = Arrays.asList("user_a", "user_b");
String reqMsg = "Inviting you to the tech discussion group";
OpenIMClient.getInstance().groupManager.inviteUserToGroup(
new OnBase<String>() {
@Override
public void onSuccess(String data) {
// Invitation request submitted successfully
}
@Override
public void onError(int code, String error) {
// Failed to send group invitation
}
},
groupID,
inviteeUserIDs,
reqMsg
);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
base | OnBase<String> | Yes | Callback handler for the asynchronous request. |
groupID | String | Yes | Globally unique ID of the target group. |
inviteeUserIDs | List<String> | Yes | List of user IDs to invite. Ensure empty strings and duplicates are removed. |
reqMsg | String | No | Optional invitation message or note. Pass an empty string if not needed. |
Return value
Upon success, data in onSuccess returns a confirmation message.
State changes after the call
- Callback confirmation: The
onSuccesscallback indicates that the invitation request was accepted by the server. - Asynchronous event delivery: When users join successfully, group members receive the
onGroupMemberAddedevent containing the newly joinedGroupMembersInfo. The client should merge new members into the member roster usinggroupID:userIDas the unique key. If verification is required, administrators receiveonGroupApplicationAdded. - Re-query calibration: To reconcile member rosters and member counts after intermittent connection loss, call
getGroupMemberList()orgetSpecifiedGroupsInfo().
For complete listener registration and lifecycle management, see Group overview.
Was this page helpful?