Chat SDKs Flutter v4
Chat SDKs Flutter
Chat SDKs
Flutter
Version 4
Operators of an open or group channel can restrict selected users from sending messages to the channel using the mute feature. A muted user remains in the channel and is allowed to view the messages but they can't send any messages to the channel until the operators unmute them. Operators can mute and unmute users using the following code.
try {
final openChannel = await OpenChannel.getChannel('CHANNEL_URL');
// Mute a user.
await openChannel.muteUser(userId: 'USER_ID', seconds: SECONDS);
// The user is successfully muted from the channel.
// You can notify the user of being muted by displaying a prompt.
// Unmute a user.
await openChannel.unmuteUser(userId: 'USER_ID');
// The user is successfully unmuted from the channel.
// You can notify the user of being unmuted by displaying a prompt.
} catch (e) {
// Handle error.
}
try {
final groupChannel = await GroupChannel.getChannel('CHANNEL_URL');
// Mute a user.
await groupChannel.muteUser(
userId: 'USER_ID',
seconds: SECONDS,
description: 'DESCRIPTION',
);
// The user is successfully muted.
// You could notify the user of being muted by displaying a prompt.
// Unmute a user.
await groupChannel.unmuteUser(userId: USER_ID);
// The user is successfully unmuted.
// You could notify the user of being unmuted by displaying a prompt.
} catch (e) {
// Handle error.
}