// 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
const reply = await client.connectUser(user, token); // reply.me.channel_mutes contains the list of channel mutes console.log(reply.me.channel_mutes); const channel = client.channel("messaging", "channel-id"); // mute channel for current user await channel.mute(); // mute channel for a user (server-side) await channel.mute({ user_id: userId }); // mute a channel for 2 weeks await channel.mute({ expiration: moment.duration(2, "weeks") }); // mute a channel for 10 seconds await channel.mute({ expiration: 10000 }); // check if channel is muted // { muted: true | false, createdAt: Date | null, expiresAt: Date | null} channel.muteStatus();import Stream Chat let controller = chatClient.channelController(for: .init(type: .messaging, id: "general")) // mute channel controller.muteChannel { error in if let error = error { // handle error print(error) } }// mute channel for current user await channel.mute(); // mute a channel for 2 weeks await channel.mute(expiration: Duration(days: 15)); // mute a channel for 10 seconds await channel.mute(expiration: Duration(seconds: 10)); // check if channel is muted channel.isMuted;// mute channel for current user Channel->Mute(); // mute a channel for 2 weeks Channel->Mute({FTimespan::FromDays(15.)}); // mute a channel for 10 seconds Channel->Mute({FTimespan::FromSeconds(10.)}); // check if channel is muted Channel->IsMuted();$channel->mute("john"); // With expiration $channel->mute("john", expirationInMilliSeconds: 1000);channel.mute("john") # With expiration channel.mute("john", expiration=30000)# require 'stream-chat' channel.mute("john") # With expiration channel.mute("john", 1000)await channelClient.MuteChannelAsync(new ChannelMuteRequest { ChannelCids = new[] { "<channel-cid-here>" }, UserId = "john", }); // With expiration await channelClient.MuteChannelAsync(new ChannelMuteRequest { ChannelCids = new[] { "<channel-cid-here>" }, UserId = "john", Expiration = 1000, });channel.Mute(ctx, "john", nil) // With expiration exp := 6 * time.Hour channel.Mute(ctx, "john", &exp)// Android SDK // Mute a channel ChannelClient channelClient = client.channel("messaging", "general"); channelClient.mute().enqueue(result -> { if (result.isSuccess()) { // Channel is muted } else { // Handle result.error() } }); // Get list of muted channels when user is connected User user = new User(); user.setId("user-id"); client.connectUser(user, "token").enqueue(result -> { if (result.isSuccess()) { // Result contains the list of channel mutes List<ChannelMute> mutes = result.data().getUser().getChannelMutes(); } }); // Get updates about muted channels client.subscribeFor( new Class[]{NotificationChannelMutesUpdatedEvent.class}, channelsMuteEvent -> { List<ChannelMute> mutes = ((NotificationChannelMutesUpdatedEvent) channelsMuteEvent).getMe().getChannelMutes(); } ); // Backend SDK Channel.mute() .channelCid(channel.getType() + ":" + channel.getId()) .user(user) .expiration(TimeUnit.MILLISECONDS.convert(14, TimeUnit.DAYS)) // Optionally set mute duration .request();await channel.MuteChannelAsync();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.
// Filter for all channels excluding muted ones val notMutedFilter = Filters.and( Filters.eq("muted", false), Filters.`in`("members", listOf(currentUserId)), ) // Filter for muted channels val mutedFilter = Filters.eq("muted", true) // Executing a channels query with either of the filters client.queryChannels(QueryChannelsRequest( filter = filter, // Set the correct filter here offset = 0, limit = 10, )).enqueue { result -> if (result is Result.Success) { val channels: List<Channel> = result.value } else { // Handle Result.Failure } }// retrieve all channels excluding muted ones await client.queryChannels({ members: { $in: [userId] }, muted: false }); // retrieve all muted channels await client.queryChannels({ muted: true });let controller = chatClient.channelListController( query: .init( filter: .equal(.muted, to: true) ) ) controller.synchronize { error in print(error ?? controller.channels) }// retrieve all channels excluding muted ones await client.queryChannels( filter: { 'members': { r'$in': [userId], }, 'muted': false, } ); // retrieve all muted channels await client.queryChannels( filter: { 'muted': true, } );// retrieve all channels excluding muted ones const FFilter NotMuted = FFilter::And({ FFilter::In(TEXT("members"), {UserId}), FFilter::Equal(TEXT("muted"), false), }); Client->QueryChannels(NotMuted); // retrieve all muted channels const FFilter Muted = FFilter::Equal(TEXT("muted"), true); Client->QueryChannels(Muted);$client->queryChannels(['muted' => true]);client.query_channels({"muted": True})client.query_channels({ 'muted' => true })await channelClient.QueryChannelsAsync(QueryChannelsOptions.Default.WithFilter(new Dictionary<string, object> { { "muted", true }, }));client.QueryChannels(ctx, &QueryOption{ Filter: map[string]interface{}{ "muted": true, }, })// Android SDK // Filter for all channels excluding muted ones FilterObject notMutedFilter = Filters.and( Filters.eq("muted", false), Filters.in("members", Arrays.asList(currentUserId)) ); // Filter for muted channels FilterObject mutedFilter = Filters.eq("muted", true); // Executing a channels query with either of the filters int offset = 0; int limit = 10; QuerySorter<Channel> sort = new QuerySortByField<>(); int messageLimit = 0; int memberLimit = 0; client.queryChannels(new QueryChannelsRequest( filter, // Set the correct filter here offset, limit, sort, messageLimit, memberLimit)).enqueue(result -> { if (result.isSuccess()) { List<Channel> channels = result.data(); } else { // Handle result.error() } }); // Backend SDK // retrieve all channels excluding muted ones Channel.list() .filterCondition("muted", false) // Or 'true' for selected muted channels .filterCondition(FilterCondition.in("members", userId)) .request();// Will be implemented soon, raise a GitHub issue if you need this feature https://github.com/GetStream/stream-chat-unity/issues/Remove a Channel Mute
Use the unmute method to restore normal notifications and unread behavior for a channel.
// Unmute channel for current user channelClient.unmute().enqueue { result -> if (result is Result.Success) { // Channel is unmuted } else { // Handle Result.Failure } }// unmute channel for current user await channel.unmute(); // unmute channel for a user (server-side) await channel.unmute({ user_id: userId });import Stream Chat let controller = chatClient.channelController(for: .init(type: .messaging, id: "general")) // unmute channel controller.unmuteChannel { error in if let error = error { // handle error print(error) } }// unmute channel for current user await channel.unmute(); // unmute channel for a user (server-side) await channel.unmute({ user_id: userId });// unmute channel for current user Channel->Unmute();$channel->unmute("john");channel.unmute("john")channel.unmute("john")await channelClient.UnmuteChannelAsync(new ChannelUnmuteRequest { ChannelCids = new[] { "<channel-cid-here>" }, UserId = "john", });channel.Unmute(ctx, "john")// Android SDK // Unmute channel for current user channelClient.unmute().enqueue(result -> { if (result.isSuccess()) { // Channel is unmuted } else { // Handle result.error() } }); // Backend SDK Channel.unmute().channelCid(cid).userId(userId).request();await channel.UnmuteChannelAsync();