fetchMemberAttributes method
~english Gets all custom attributes of a group member.
Param groupId The group ID.
Param userId The user ID of the target group member.
Returns The custom attributes map of the group member.
Throws Exception description, see EMError. ~end
~chinese 获取单个群成员所有自定义属性。
Param groupId 群组 ID。
Param userId 要获取属性的群成员用户 ID。
Return 群成员自定义属性键值对。
Throws 如果有异常会在这里抛出,包含错误码和错误描述,详见 EMError。 ~end
Implementation
Future<Map<String, String>> fetchMemberAttributes({
required String groupId,
String? userId,
}) async {
try {
Map req = {'groupId': groupId};
req.putIfNotNull('userId', userId);
Map result = await Client.instance.groupManager
.callNativeMethod(ChatMethodKeys.fetchMemberAttributesFromGroup, req);
EMError.hasErrorFromResult(result);
Map<String, String> ret = {};
result[ChatMethodKeys.fetchMemberAttributesFromGroup]
.forEach((key, value) {
ret[key] = value;
});
return ret;
} catch (e) {
rethrow;
}
}