# Muting or Hiding Channels

## Muting Channels

Messages added to a channel will not trigger push notifications, unhide a channel, nor change the unread count for the users that muted it. By default, mutes stay in place indefinitely until the user removes it; however, you can optionally set an expiration time. The list of muted channels and their expiration time is returned when the user connects.

<codetabs>

<codetabs-item value="kotlin" label="Kotlin">

```kotlin
// 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
}
```

</codetabs-item>

<codetabs-item value="javascript" label="JavaScript">

```js
const reply = await client.setUser(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();
```

</codetabs-item>

<codetabs-item value="swift" label="Swift">

```swift
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)
  }
}
```

</codetabs-item>

<codetabs-item value="dart" label="Dart">

```dart
// 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;
```

</codetabs-item>

<codetabs-item value="unreal" label="Unreal">

```cpp
// 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();
```

</codetabs-item>

<codetabs-item value="php" label="PHP">

```php
$channel->mute("john");

// With expiration
$channel->mute("john", expirationInMilliSeconds: 1000);
```

</codetabs-item>

<codetabs-item value="python" label="Python">

```python
channel.mute("john")

# With expiration
channel.mute("john", expiration=30000)
```

</codetabs-item>

<codetabs-item value="ruby" label="Ruby">

```ruby
# require 'stream-chat'

channel.mute("john")

# With expiration
channel.mute("john", 1000)
```

</codetabs-item>

<codetabs-item value="csharp" label="C#">

```csharp
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,
});
```

</codetabs-item>

<codetabs-item value="go" label="Go">

```go
channel.Mute(ctx, "john", nil)

// With expiration
exp := 6 * time.Hour
channel.Mute(ctx, "john", &exp)
```

</codetabs-item>

<codetabs-item value="java" label="Java">

```java
// 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();
```

</codetabs-item>

<codetabs-item value="unity" label="Unity">

```csharp
await channel.MuteChannelAsync();
```

</codetabs-item>

</codetabs>

<admonition type="info">

Messages added to muted channels do not increase the unread messages count.

</admonition>

### Query Muted Channels

Muted channels can be filtered or excluded by using the `muted` in your query channels filter.

<codetabs>

<codetabs-item value="kotlin" label="Kotlin">

```kotlin
// 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
  }
}
```

</codetabs-item>

<codetabs-item value="javascript" label="JavaScript">

```js
// retrieve all channels excluding muted ones
await client.queryChannels({ members: { $in: [userId] }, muted: false });

// retrieve all muted channels
await client.queryChannels({ muted: true });
```

</codetabs-item>

<codetabs-item value="swift" label="Swift">

```swift
let controller = chatClient.channelListController(
  query: .init(
    filter: .equal(.muted, to: true)
  )
)
controller.synchronize { error in
  print(error ?? controller.channels)
}
```

</codetabs-item>

<codetabs-item value="dart" label="Dart">

```dart
// 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,
  }
 );
```

</codetabs-item>

<codetabs-item value="unreal" label="Unreal">

```cpp
// 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);
```

</codetabs-item>

<codetabs-item value="php" label="PHP">

```php
$client->queryChannels(['muted' => true]);
```

</codetabs-item>

<codetabs-item value="python" label="Python">

```python
client.query_channels({"muted": True})
```

</codetabs-item>

<codetabs-item value="ruby" label="Ruby">

```ruby
client.query_channels({ 'muted' => true })
```

</codetabs-item>

<codetabs-item value="csharp" label="C#">

```csharp
await channelClient.QueryChannelsAsync(QueryChannelsOptions.Default.WithFilter(new Dictionary<string, object>
{
  { "muted", true },
}));
```

</codetabs-item>

<codetabs-item value="go" label="Go">

```go
client.QueryChannels(ctx, &QueryOption{
	Filter: map[string]interface{}{
		"muted": true,
	},
})
```

</codetabs-item>

<codetabs-item value="java" label="Java">

```java
// 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();
```

</codetabs-item>

<codetabs-item value="unity" label="Unity">

```csharp
// Will be implemented soon, raise a GitHub issue if you need this feature https://github.com/GetStream/stream-chat-unity/issues/
```

</codetabs-item>

</codetabs>

### Remove a Channel Mute

Whenever you need to unmute, you are able to.

<codetabs>

<codetabs-item value="kotlin" label="Kotlin">

```kotlin
// Unmute channel for current user
channelClient.unmute().enqueue { result ->
  if (result is Result.Success) {
    // Channel is unmuted
  } else {
    // Handle Result.Failure
  }
}
```

</codetabs-item>

<codetabs-item value="javascript" label="JavaScript">

```js
// unmute channel for current user
await channel.unmute();

// unmute channel for a user (server-side)
await channel.unmute({ user_id: userId });
```

</codetabs-item>

<codetabs-item value="swift" label="Swift">

```swift
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)
  }
}
```

</codetabs-item>

<codetabs-item value="dart" label="Dart">

```dart
// unmute channel for current user
await channel.unmute();

// unmute channel for a user (server-side)
await channel.unmute({ user_id: userId });
```

</codetabs-item>

<codetabs-item value="unreal" label="Unreal">

```cpp
// unmute channel for current user
Channel->Unmute();
```

</codetabs-item>

<codetabs-item value="php" label="PHP">

```php
$channel->unmute("john");
```

</codetabs-item>

<codetabs-item value="python" label="Python">

```python
channel.unmute("john")
```

</codetabs-item>

<codetabs-item value="ruby" label="Ruby">

```ruby
channel.unmute("john")
```

</codetabs-item>

<codetabs-item value="csharp" label="C#">

```csharp
await channelClient.UnmuteChannelAsync(new ChannelUnmuteRequest
{
  ChannelCids = new[] { "<channel-cid-here>" },
  UserId = "john",
});
```

</codetabs-item>

<codetabs-item value="go" label="Go">

```go
channel.Unmute(ctx, "john")
```

</codetabs-item>

<codetabs-item value="java" label="Java">

```java
// 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();
```

</codetabs-item>

<codetabs-item value="unity" label="Unity">

```csharp
await channel.UnmuteChannelAsync();
```

</codetabs-item>

</codetabs>

## Hiding a Channel

Hiding a channel will remove it from query channel requests for that user until a new message is added. Please keep in mind that hiding a channel is only available to members of that channel. Hidden channels may still have unread messages and you may wish to [mark the channel as read](/chat/docs/javascript/unread/) prior to hiding it.

Optionally you can also clear the entire message history of that channel for the user. This way, when a new message is received, it will be the only one present in the channel.

<codetabs>

<codetabs-item value="kotlin" label="Kotlin">

```kotlin
// Hides the channel until a new message is added there
channelClient.hide().enqueue { result ->
  if (result is Result.Success) {
    // Channel is hidden
  } else {
    // Handle Result.Failure
  }
}

// Shows a previously hidden channel
channelClient.show().enqueue { result ->
  if (result is Result.Success) {
    // Channel is shown
  } else {
    // Handle Result.Failure
  }
}

// Hide the channel and clear the message history
channelClient.hide(clearHistory = true).enqueue { result ->
  if (result is Result.Success) {
    // Channel is hidden
  } else {
    // Handle Result.Failure
  }
}
```

</codetabs-item>

<codetabs-item value="javascript" label="JavaScript">

```js
// hides the channel until a new message is added there
await channel.hide();

// hides the channel until a new message is added there. This also clears the history for the user
await channel.hide(null, true);

// shows a previously hidden channel
await channel.show();
```

</codetabs-item>

<codetabs-item value="php" label="PHP">

```php
// hides the channel until a new message is added there
$channel->hide('elon');

// shows a previously hidden channel
$channel->show('elon');
```

</codetabs-item>

<codetabs-item value="dart" label="Dart">

```dart
// hides the channel until a new message is added there
await channel.hide();

// shows a previously hidden channel
await channel.show();

// hide the channel and clear the message history
await channel.hide(clearHistory: true);
```

</codetabs-item>

<codetabs-item value="swift" label="Swift">

```swift
import Stream Chat

let controller = chatClient.channelController(for: .init(type: .messaging, id: "general"))

// hide channel
controller.hideChannel { error in
  if let error = error {
    // handle error
    print(error)
  }
}

// show channel
controller.showChannel { error in
  if let error = error {
    // handle error
    print(error)
  }
}

// hide channel and clear message history
controller.hideChannel(clearHistory: true) { error in
  if let error = error {
    // handle error
    print(error)
  }
}
```

</codetabs-item>

<codetabs-item value="unreal" label="Unreal">

```cpp
// Android SDK

// hides the channel until a new message is added there
Channel->Hide();

// shows a previously hidden channel
Channel->Show();

// hide the channel and clear the message history
Channel->Hide(true);

// Backend SDK

// hide channel
Channel.hide(type, id)
  .clearHistory(true) // Optionally clear history
  .userId(userId)
  .request();

// shows a previously hidden channel
Channel.show(type, id).userId(userId).request();
```

</codetabs-item>

<codetabs-item value="php" label="PHP">

```php
// hides the channel until a new message is added there
$channel->hide("john");

// shows a previously hidden channel
$channel->show("john");
```

</codetabs-item>

<codetabs-item value="python" label="Python">

```python
# hides the channel until a new message is added there
channel.hide("john");

# shows a previously hidden channel
channel.show("john");
```

</codetabs-item>

<codetabs-item value="ruby" label="Ruby">

```ruby
# hides the channel until a new message is added there
channel.hide("john");

# shows a previously hidden channel
channel.show("john");
```

</codetabs-item>

<codetabs-item value="csharp" label="C#">

```csharp
// hides the channel until a new message is added there
await channelClient.HideAsync("<channel-type>", "<channel-id>", "john");

// shows a previously hidden channel
await channelClient.ShowAsync("<channel-type>", "<channel-id>", "john");
```

</codetabs-item>

<codetabs-item value="go" label="Go">

```go
// hides the channel until a new message is added there
channel.hide(ctx, "john");

// shows a previously hidden channel
channel.show(ctx, "john");
```

</codetabs-item>

<codetabs-item value="java" label="Java">

```java
// Hides the channel until a new message is added there
channelClient.hide(false).enqueue(result -> {
  if (result.isSuccess()) {
    // Channel is hidden
  } else {
    // Handle result.error()
  }
});

// Shows a previously hidden channel
channelClient.show().enqueue(result -> {
  if (result.isSuccess()) {
    // Channel is shown
  } else {
    // Handle result.error()
  }
});

// Hide the channel and clear the message history
channelClient.hide(true).enqueue(result -> {
  if (result.isSuccess()) {
    // Channel is hidden
  } else {
    // Handle result.error()
  }
});
```

</codetabs-item>

<codetabs-item value="unity" label="Unity">

```csharp
// Hide a channel
await channel.HideAsync();

// Show previously hidden channel
await channel.ShowAsync();
```

</codetabs-item>

</codetabs>

<admonition type="info">

You can still retrieve the list of hidden channels using the `{ "hidden" : true }` query parameter.

</admonition>

---

This page was last updated at 2025-08-15T14:14:35.775Z.

For the most recent version of this documentation, visit [https://getstream.io/chat/docs/ios-swift/muting_channels/](https://getstream.io/chat/docs/ios-swift/muting_channels/).