setMemberAttributes method

Future<void> setMemberAttributes({
  1. required String groupId,
  2. required Map<String, String> attributes,
  3. String? userId,
})

~english Sets custom attributes of a group member.

Param groupId The group ID.

Param userId The user ID of the group member for whom the custom attributes are set. The default value is the current user ID.

Param attributes The map of custom attributes in key-value format. In a key-value pair, if the value is set to an empty string, the custom attribute will be deleted.

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

~chinese 设置群成员自定义属性。

Param groupId 群组 ID。

Param userId 要设置自定义属性的群成员的用户 ID,默认为当前用户。

Param attributes 要设置的群成员自定义属性的 map,为 key-value 格式。对于一个 key-value 键值对,若 value 设置空字符串即删除该自定义属性。

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

Implementation

Future<void> setMemberAttributes({
  required String groupId,
  required Map<String, String> attributes,
  String? userId,
}) async {
  Map req = {
    'groupId': groupId,
  };
  if (userId != null) {
    req.putIfNotNull('userId', userId);
  }
  req.putIfNotNull('attributes', attributes);
  Map result = await _channel.invokeMethod(
      ChatMethodKeys.setMemberAttributesFromGroup, req);
  try {
    ChatError.hasErrorFromResult(result);
  } on ChatError catch (e) {
    throw e;
  }
}