Tagging group channels
The channel tagging feature for group channels works the same as for direct channels. See Tagging Channels for the full API reference.
All tag operations apply to group channels in the same way they apply to direct channels. This includes adding channels to tags, removing channels from tags, removing tags from channels, getting tags for a channel, querying channels by tag with pagination, getting unread counts by tag, clearing unread counts, and deleting channels by tag.
For group-specific examples, replace DirectChannel with GroupChannel and ChannelType.DIRECT with ChannelType.GROUP.
Example: Add group channels to a tag
- Kotlin
- Java
kotlin
Tag.getTags { tagList, error ->
if (error == null && tagList != null) {
val tag = tagList.firstOrNull { it.tagId == "myTag" }
if (tag != null) {
tag.addChannels(
listOf(
ChannelIdentifier(ChannelType.GROUP, "groupId1"),
ChannelIdentifier(ChannelType.GROUP, "groupId2")
)
) { error ->
if (error == null) {
// Added successfully
}
}
}
}
}
Java
Tag.getTags((tagList, error) -> {
if (error == null && tagList != null) {
Tag tag = null;
for (Tag t : tagList) {
if ("myTag".equals(t.getTagId())) {
tag = t;
break;
}
}
if (tag != null) {
List<ChannelIdentifier> channels = new ArrayList<>();
channels.add(new ChannelIdentifier(ChannelType.GROUP, "groupId1"));
channels.add(new ChannelIdentifier(ChannelType.GROUP, "groupId2"));
tag.addChannels(channels, error2 -> {
if (error2 == null) {
// Added successfully
}
});
}
}
});
For the complete tagging API reference, see Tagging Channels.