fetchMembersAttributes method

Future<Map<String, Map<String, String>>> fetchMembersAttributes({
  1. required String groupId,
  2. required List<String> userIds,
  3. List<String>? keys,
})

~english Gets custom attributes of multiple group members by attribute key.

Param groupId The group ID.

Param userIds The array of user IDs of group members whose custom attributes are retrieved. You can pass in a maximum of 10 user IDs.

Param keys The array of keys of custom attributes to be retrieved.

Return The users attributes.

Throws A description of the exception. See EMError.

~end

~chinese 根据指定的属性 key 获取多个群成员的自定义属性。

Param groupId 群组 ID。

Param userIds 要获取自定义属性的群成员的用户 ID 数组。最多可传 10 个用户 ID。

Param keys 要获取自定义属性的 key 的数组。

Return 需要查询的用户属性。

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

Implementation

Future<Map<String, Map<String, String>>> fetchMembersAttributes({
  required String groupId,
  required List<String> userIds,
  List<String>? keys,
}) async {
  Map req = {'groupId': groupId, 'userIds': userIds};
  req.putIfNotNull("keys", keys);
  Map result = await _channel.invokeMethod(
      ChatMethodKeys.fetchMembersAttributesFromGroup, req);
  try {
    EMError.hasErrorFromResult(result);
    var map = result[ChatMethodKeys.fetchMembersAttributesFromGroup];
    Map<String, Map<String, String>> ret = {};
    if (map is Map) {
      map.keys.forEach((element) {
        if (map[element] is Map) {
          Map<String, String> value =
              Map<String, String>.from(map[element] ?? {});
          ret[element] = value;
        }
      });
    }
    return ret;
  } on EMError catch (e) {
    throw e;
  }
}