requestToJoinPublicGroup method

Future<void> requestToJoinPublicGroup(
  1. String groupId, {
  2. String? reason,
})

~english Requests to join a group.

This method works only for public groups requiring authentication, i.e., groups with the style of EMGroupStyle.PublicJoinNeedApproval.

Param groupId The group ID.

Param reason The reason for requesting to join the group.

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

~chinese 申请加入群组。

该方法仅适用于需要验证的公开群组,即类型为 EMGroupStyle.PublicJoinNeedApproval 的群组。

Param groupId 群组 ID。

Param reason 申请入群的原因。

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

Implementation

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