inviterUser method

Future<void> inviterUser(
  1. String groupId,
  2. List<String> members, {
  3. String? reason,
})

~english Invites users to join the group.

This method works only for groups with the style of EMGroupStyle.PrivateOnlyOwnerInvite, EMGroupStyle.PrivateMemberCanInvite, or EMGroupStyle.PublicJoinNeedApproval. For a group with the EMGroupStyle.PrivateOnlyOwnerInvite style, only the group owner can invite users to join the group; For a group with the EMGroupStyle.PrivateMemberCanInvite style, each group member can invite users to join the group.

Param groupId The group ID.

Param members The array of new members to invite.

Param reason The invitation reason.

Throws A description of the exception. See EMError. ~end

~chinese 邀请用户加入群组。

群类型为 EMGroupStyle.PrivateOnlyOwnerInviteEMGroupStyle.PrivateMemberCanInviteEMGroupStyle.PublicJoinNeedApproval 的群组可以邀请用户加入。

Param groupId 群组 ID。

Param members 要邀请的新成员数组。

Param reason 邀请原因。

Throws 如果有异常会在此抛出,包括错误码和错误信息,详见 EMError。 ~end

Implementation

Future<void> inviterUser(
  String groupId,
  List<String> members, {
  String? reason,
}) async {
  Map req = {
    'groupId': groupId,
    'members': members,
  };
  req.putIfNotNull("reason", reason);

  Map result = await _channel.invokeMethod(
    ChatMethodKeys.inviterUser,
    req,
  );

  try {
    EMError.hasErrorFromResult(result);
  } on EMError catch (e) {
    throw e;
  }
}