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

// Mute a channel for the current user
await channel.MuteChannelAsync();

// Mute a channel for 2 weeks (duration in milliseconds)
await channel.MuteChannelAsync(milliseconds: 14 * 24 * 60 * 60 * 1000);

// Mute a channel for 10 seconds
await channel.MuteChannelAsync(milliseconds: 10000);

// The list of channel mutes (with expiration times) is available after connect
var channelMutes = Client.LocalUserData.ChannelMutes;

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.

// Retrieve all channels excluding muted ones
var notMutedFilters = new IFieldFilterRule[]
{
    ChannelFilter.Members.In(Client.LocalUserData.UserId),
    ChannelFilter.Muted.EqualsTo(false),
};
var notMutedChannels = await Client.QueryChannelsAsync(notMutedFilters);

// Retrieve all muted channels
var mutedFilters = new IFieldFilterRule[]
{
    ChannelFilter.Muted.EqualsTo(true),
};
var mutedChannels = await Client.QueryChannelsAsync(mutedFilters);

Remove a Channel Mute

Use the unmute method to restore normal notifications and unread behavior for a channel.

await channel.UnmuteChannelAsync();