/ SDKs / Android
SDKs
Chat SDKs Android v4
Chat SDKs Android
Chat SDKs
Android
Version 4

Block and unblock other members

Copy link

A user can block another user if the user doesn't wish to receive any messages or notifications from the blocked user in a 1-to-1 group channel. In a 1-to-N group channel, the user may receive messages from the blocked user, depending on the UI settings of the chat view. In any case, notifications from the blocked user won't be delivered to the 1-to-N group channel. You can also choose whether or not to allow the user to view which users are blocked in the channel UI.


Block modes

Copy link

Sendbird application provides two blocking options: including or excluding blocked users when sending invitations, and turning on or off notifications from blocked users. Explicit and classic block modes have been deprecated and are only supported for customers who started using them before they were deprecated.

  • Including or excluding blocked users when sending invitations: Determines whether or not to automatically filter out blocked users when a user invites a group of users to a new group channel. By default, blocked users are included when sending invitations. The value of this option can be changed by Sendbird if your Sendbird application isn't integrated to the client app. If you want to change the value, contact our sales team.

  • Turning on or off notifications from blocked users: Determines whether or not to receive message notifications from the blocked user in a specific 1-to-N group channel where they are both members. By default, a user doesn't receive notifications from blocked users. The value of this option can be set to individual channels. If you want to use this option, contact our sales team.

The following table explains what happens to a user's chat experience when the user blocks another user in a 1-to-1 or 1-to-N group channel. In the case of a 1-to-1 group channel, the block mode is only maintained with the original members. If users other than the original members are added, the rules for 1-to-N group channel begin to apply.

Block consequences by channel type

Copy link
Channel typeChannel listNotificationsMessages

1-to-1 group channel

A user's channel list isn't updated in response to the blocked user's messages.

A user can't receive notifications for the messages from the blocked user.

A user can only see the messages that the blocked user has sent before being blocked. Even though messages sent from the blocked user aren't delivered to the channel, they are saved in the database and only displayed in the blocked user's channel view. This means that the blocked user isn't aware of their blocked status.

* If the blocked user is unblocked, a user can see all the messages from the blocked user except those that were sent during the blocking period.

1-to-N group channel

A user's channel list is updated in response to a blocked user's message.

By default, a user can't receive message notifications from a blocked user. If the option is turned on, the user can receive message notifications from the blocked user.

All messages from blocked users are delivered to the channel. You can choose whether or not a user can view the messages from the blocked users in the channel UI.


How to use block modes

Copy link

You can let users block and unblock other users by implementing the following code in your client app.

KotlinKTX
// Block a user.
SendbirdChat.blockUser(USER) { user, e ->
    if (e != null) {
        // Handle error.
    }

    // The blocked user can be retrieved through the user parameter of the onBlocked() callback method.
    // ...
}

// Unblock a user.
SendbirdChat.unblockUser(USER) { e ->
    if (e != null) {
        // Handle error.
    }

    // The blocked user can be retrieved through the user parameter of the onBlocked() callback method.
    // ...
}

Note: You can use the blockUser() and unblockUser() methods, instead of the blockUser() and unblockUser() methods, as they perform the same actions.