Chat / iOS
Chat iOS v4
Chat iOS
Chat
iOS
Home
/
Chat
/
iOS
/
User
This is the new Docs for Chat SDK v4 for iOS. To see the previous Docs, click here.

Mute and unmute a user

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.

// Mute a user.
channel.muteUser(USER, seconds: SECONDS, description: DESCRIPTION) { (error) in
    guard error == nil else {
        // Handle error.
        return
    }

    // The user is successfully muted in the channel.
    // You can display a message to let the user know they have been muted.
}

// Unmute a user.
channel.unmuteUser(USER) { (error) in
    guard error == nil else {
        // Handle error.
        return
    }

    // The user is successfully unmuted in the channel.
    // You can display a message to let the user know they have been unmuted.
}

Note: Instead of the muteUser(_:seconds:description:completionHandler:) and unmuteUser(_:completionHandler:) methods, you can also use muteUser(userId:seconds:description:completionHandler:) and unmuteUser(userId:completionHandler:), as they perform the same action.