addMembers method

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

~english Adds users to the group.

Only the group owner or admin can call this method.

Param groupId The group ID.

Param members The array of new members to add.

Param welcome The welcome message.

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

~chinese 向群组中添加新成员。

仅群主和管理员可调用此方法。

Param groupId 群组 ID。

Param members 要添加的新成员数组。

Param welcome 欢迎消息。

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

Implementation

Future<void> addMembers(
  String groupId,
  List<String> members, {
  String? welcome,
}) async {
  Map req = {'groupId': groupId, 'members': members};
  req.putIfNotNull("welcome", welcome);
  Map result = await _channel.invokeMethod(ChatMethodKeys.addMembers, req);
  try {
    EMError.hasErrorFromResult(result);
  } on EMError catch (e) {
    throw e;
  }
}