inviterUser method
~english Invites users to join the group.
This method works only for groups with the style of ChatGroupStyle.PrivateOnlyOwnerInvite, ChatGroupStyle.PrivateMemberCanInvite, or ChatGroupStyle.PublicJoinNeedApproval. For a group with the ChatGroupStyle.PrivateOnlyOwnerInvite style, only the group owner can invite users to join the group; For a group with the ChatGroupStyle.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 ChatError. ~end
~chinese 邀请用户加入群组。
群类型为 ChatGroupStyle.PrivateOnlyOwnerInvite、ChatGroupStyle.PrivateMemberCanInvite 和 ChatGroupStyle.PublicJoinNeedApproval 的群组可以邀请用户加入。
- 对于 ChatGroupStyle.PrivateOnlyOwnerInvite 属性的群组,仅群主可邀请用户入群。
- 对于 ChatGroupStyle.PrivateMemberCanInvite 属性的群组,群成员可邀请用户入群。
- 对于 ChatGroupStyle.PublicJoinNeedApproval 属性的群组,仅群主可邀请用户加入。
Param groupId
群组 ID。
Param members
要邀请的新成员数组。
Param reason
邀请原因。
Throws 如果有异常会在此抛出,包括错误码和错误信息,详见 ChatError。 ~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 {
ChatError.hasErrorFromResult(result);
} on ChatError catch (e) {
throw e;
}
}