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

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

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.

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

Remove a Channel Mute

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

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