I will be adding metadata on channel say organization_id
and value will be let say id_1
. How can ask sendbird GroupChannelListQuery
, give me all the channels in which i am a member and metadata key organization_id
is id_1
?
Hey @akshay.manathkar welcome to the Sendbird community!!
As far as I can see there is no way to query channels by using only the GroupChannelListQuery
.
However, you can filter channels after you retrieve them with the GroupChannelListQuery
like this:
private void getChannelsWithMetadata() {
GroupChannelListQuery listQuery = GroupChannel.createMyGroupChannelListQuery();
listQuery.setIncludeEmpty(true);
listQuery.setMemberStateFilter(GroupChannelListQuery.MemberStateFilter.JOINED);
listQuery.setIncludeMetadata(true);
listQuery.next(new GroupChannelListQuery.GroupChannelListQueryResultHandler() {
@Override
public void onResult(List<GroupChannel> list, SendBirdException e) {
// A list of matching group channels is successfully retrieved.
// Through the "list" parameter of the onResult() callback method,
// you can access the data of each group channel from the result list that Sendbird server has passed to the callback method.
List<GroupChannel> channels = list;
List<String> keys = new ArrayList<String>();
keys.add("organization_id");
if (channels != null) {
for (int i = 0; i < channels.size(); i++) {
channels.get(i).getMetaData(keys, new BaseChannel.MetaDataHandler() {
@Override
public void onResult(Map<String, String> map, SendBirdException e) {
if ("id_1".equals(map.get("organization_id"))) {
Log.i("Channel Metadata: ", String.valueOf(map));
}
}
});
}
}
}
});
}