Application

When you're ready to start building, you should understand that a SendBird application has some restrictions on its functionalities to maintain the stability of chat service and also gives you ways to work with the application users. With the following information, you can integrate SendBird to your own application for us to work better together.


Default settings

To prevent some users' abnormal activities, a SendBird application has the following limits on the number of messages per second which a user can send and a channel can display.

Imposed on Limit If exceeded
User 5 messages per second Excess messages are not sent to a channel, and not saved in the database.
Channel 5 messages per second Excess messages are not displayed in a channel, but saved in the database.

The limits above are basic numbers of our premium features, spam flood protection and smart throttling, which could be adjusted in some situations. Currently in the dashboard, paying customers can control the limit of the smart throttling.


Manage connections with SendBird server

Unlike the iOS and Android SDKs, the JavaScript SDK doesn't manage a connection to the SendBird server when the state (foreground/background) of an application changes. In that context, you should call connect() or disconnect() explicitly depending on how you implement your use cases.

One user ID can make connections up to 30 devices or browsers simultaneously. All connections from one user ID are counted and reflected in the CCU (concurrently connected users) which is our service's billing standard, so please be careful to use it.


Retrieve a list of all or certain users in an application

You can retrieve a list of all users in a SendBird application by creating a ApplicationUserListQuery object. The next() method returns a list of User objects which contain information about users within the application.

// In case of retrieving all users
var sb = SendBird.getInstance();
var applicationUserListQuery = sb.createApplicationUserListQuery();
applicationUserListQuery.next(function(users, error) {
    if (error) {
        return;
    }
});

With the several different types of filters the ApplicationUserListQuery object provides, you can retrieve a list of the specific users that match the values in the filters. Currently the ApplicationUserListQuery object supports the following three filters:

  • UserID filter: filtering users by specifying a list of userIDs.
  • MetaDataKey filter: filtering users by specifying a metadata key.
  • MetaDataValue filter: filtering users by specifying a list of metadata values.
// In case of retrieving certain users using the UserID filter
var applicationUserListQuery1 = sb.createApplicationUserListQuery();
applicationUserListQuery1.userIdsFilter = ['Harry', 'Jay', 'Jin'];
applicationUserListQuery1.next(function(users, error) {
    if (error) {
        return;
    }
});

// In case of retrieving certain users using the MetaDataKey and MetaDataValue filter
var applicationUserListQuery2 = sb.createApplicationUserListQuery();
applicationUserListQuery2.metaDataKeyFilter = ['hobby'];
applicationUserListQuery2.metaDataValueFilter = ['movie', 'book', 'exercise'];
applicationUserListQuery2.next(function(users, error) {
    if (error) {
        return;
    }
});

Block and unblock other users in an application

A user can block other users to stop receiving any further messages from them in 1-on-1 group channels. When joining 1-on-N group channels, a user will be notified if a user they have blocked is in the channel.
At the application level, by using the SendBird Dashboard or Platform API, an admin or operator can also shadow-block users with abnormal or inappropriate activities attempting to open 1-on-1 group channels with other users. The following tables describe the block functionality in further detail.

Block (user-level)

A SendBird application supports two blocking modes at the application level: explicit and silent. The classic mode is now deprecated and only supported for customers who have been using it since before.

How explicit mode works:
Group channel Messages Push notification Channel list
1-on-1 New messages from a blocked user will not be delivered to a channel, and an error for sending the message returned to a blocking user. A blocked user is aware of their blocked status.

A blocking user can see the messages that a blocked user has sent before blocking.

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

A blocking user will not be notified that a blocked user sent a message. A blocking user's channel list will not be updated and rearranged due to messages from a blocked user.
1-on-N (group chat) All the messages from blocked users are delivered to a channel. A blocking user will be informed of which users they have blocked in a channel. Messages sent from blocked users will be notified to a blocking user. A blocking user's channel list will be updated and rearranged due to messages from blocked users.
How silent mode works:
Group channel Messages Push notification Channel list
1-on-1 New messages sent from a blocked user will not be delivered to a channel, but are saved and displayed to a blocked user's channel view. A blocked user is not aware of their blocked status.

A blocking user can see the messages that a blocked user has sent before blocking.

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

A blocking user will not be notified that a blocked user sent a message. A blocking user's channel list will not be updated and rearranged due to messages from a blocked user.
1-on-N (group chat) All the messages from blocked users are delivered to a channel. A blocking user will be informed of which users they have blocked in a channel. Messages sent from blocked users will be notified to a blocking user. A blocking user's channel list will be updated and rearranged due to messages from blocked users.
How classic mode works:
Group channel Messages Push notification Channel list
1-on-1 New messages from a blocked user will not be delivered to a channel, but are saved and displayed to a blocked user's channel view. A blocked user is not aware of their blocked status.

A blocking user can't see all the messages that a blocked user has sent.

A blocking user will not be notified that a blocked user sent a message. A blocking user's channel list will not be updated and rearranged due to messages from a blocked user.
1-on-N (group chat) All the messages sent from blocked users are delivered to a channel. A blocking user can't see all messages that blocked users have sent so far. Messages sent from blocked users will not be notified to a blocking user. A blocking user's channel list will not be updated and rearranged due to messages from a blocked users.

Note: The default blocking mode is explicit. This can be manually adjusted only by our side before integrating a SendBird application. Once set at the application level, a blocking mode can no longer be changed. If you want to use the silent mode, please contact our engineering team for further assistance.

Shadow-block (admin-level)

The 1-on-1 group channels created by a shadow-blocked user are not visible to other users. Messages sent from a shadow-blocked user will not be delivered to the channel, but are saved and displayed to a shadow-blocked user's channel view. Thus a shadow-blocked user is not aware of their blocked status.

Note: As this is one of SendBird's Premium Features, please contact our sales team for further assistance.

You can make users block and unblock other user by implementing the following code to your client app.

// In case of blocking a user
var sb = SendBird.getInstance();
sb.blockUser(USER, function(user, error) {
    if (error) {
        return;
    }
});

Note: You can also use blockUserWithUserId() and unblockUserWithUserId() methods, instead of blockUser() and unblockUser() methods, as they have same functionalities. Please see our API reference on bloackUserWithUserId() and unblockUserWithUserID()


Retrieve a list of all or certain blocked users in an application

You can also retrieve a list of all blocked users in SendBird application by creating a BlockedUserListQuery object. The next() method returns a list of User objects which contain information about blocked users.

//In case of retrieving all blocked users
var sb = SendBird.getInstance();
var blockedUserlistQuery = sb.createBlockedUserListQuery();
blockedUserlistQuery.next(function(users, error) {
    if (error) {
        return;
    }
});

With the UserID filter the BlockedUserListQuery object provides, you can retrieve a list of the blocked users that match the user IDs in the filter.

//In case of retrieving certain blocked users using the UserID filter
var blockedUserListQuery1 = sb.createBlockedUserListQuery();
blockedUserListQuery1.userIdsFilter = ['John', 'Daniel', 'Jeff'];
blockedUserListQuery1.next(function(users, error) {
    if (error) {
        return;
    }
});

Check if a certain user is online

You can check if a certain user is currently connected to the SendBird server.

var sb = SendBird.getInstance();
var ApplicationUserListQuery = sb.createApplicationUserListQuery();
applicationUserListQuery.userIdsFilter = ['Jeff'];
applicationUserListQuery.next(function(users, error) {
    if (error) {
        return;
    }

    if(users[0].connectionStatus === sb.User.ONLINE) {
        // User.connectionStatus consists of NON_AVAILABLE, ONLINE, and OFFLINE.
    }
});