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.

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

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

Remove a Channel Mute

Whenever you need to unmute, you are able to.

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

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 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.

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

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

© Getstream.io, Inc. All Rights Reserved.