// Mute a channel
val channelClient = client.channel("messaging", "general")
channelClient.mute().enqueue { result ->
if (result is Result.Success) {
// Channel is muted
} else {
// Handle Result.Failure
}
}
// Get list of muted channels when user is connected
client.connectUser(User("user-id"), "token")
.enqueue { result ->
if (result is Result.Success) {
val user = result.value.user
// Result contains the list of channel mutes
val mutes: List<ChannelMute> = user.channelMutes
}
}
// Get updates about muted channels
client.subscribeFor<NotificationChannelMutesUpdatedEvent> { event ->
val mutes: List<ChannelMute> = event.me.channelMutes
}Muting Channels
Muting a channel prevents it from triggering push notifications, unhiding, or incrementing the unread count for that user.
By default, mutes remain active indefinitely until removed. You can optionally set an expiration time. The list of muted channels and their expiration times is returned when the user connects.
Mute a Channel
using GetStream;
using GetStream.Models;
var client = new StreamClient("{{ api_key }}", "{{ api_secret }}");
var chat = new ChatClient(client);
// Mute
await chat.MuteChannelAsync(new MuteChannelRequest
{
ChannelCids = new List<string> { "messaging:channel-id" },
UserID = "john"
});
// With expiration (in milliseconds)
await chat.MuteChannelAsync(new MuteChannelRequest
{
ChannelCids = new List<string> { "messaging:channel-id" },
UserID = "john",
Expiration = 1000
});Messages added to muted channels do not increase the unread messages count.
Query Muted Channels
Muted channels can be filtered or excluded by using the muted in your query channels filter.
using GetStream;
using GetStream.Models;
var client = new StreamClient("{{ api_key }}", "{{ api_secret }}");
var chat = new ChatClient(client);
// Query muted channels is not directly available; use the mute/unmute methods above.
// Muted channel state is returned when the user connects.Remove a Channel Mute
Use the unmute method to restore normal notifications and unread behavior for a channel.
using GetStream;
using GetStream.Models;
var client = new StreamClient("{{ api_key }}", "{{ api_secret }}");
var chat = new ChatClient(client);
// Unmute
await chat.UnmuteChannelAsync(new UnmuteChannelRequest
{
ChannelCids = new List<string> { "messaging:channel-id" },
UserID = "john"
});