The Chat SDK simplifies chat features into an effortless and straightforward process. To send your first message, do the following steps:
Note: The methods in the following steps are all asynchronous, excluding the
new SendBird(). This means that when using asynchronous methods, your client app must receive success callbacks from Sendbird server through callback functions in order to proceed to the next step. A good way to do this is the nesting of methods: Go to Step 4: Enter the channel to learn more about how to nest the
Pass in the App ID of the Sendbird application you created earlier in the dashboard to initialize the Chat SDK.
Connect a user to Sendbird server using their unique user ID. Any untaken user ID is automatically registered as a new user to your Sendbird application before being connected, while an existing ID is allowed to log in directly.
Note: Go to the Authentication page to learn more about authenticating with an access token.
Create an open channel. Once created, all users in your Sendbird application can easily participate in the channel.
Note: In a similar fashion, you can create a group channel with inviting users as new members to the channel.
Enter the channel to send and receive messages.
And finally, send a message to the channel! There are three types: a user message is a plain text, a file message is a binary file, such as an image or PDF, and an admin message is a plain text sent through the dashboard or Chat API for special purpose.
In a callback, the
error parameter is passed last in order by default. For example, the
connect() method below returns parameters in
(user, error) order.
You can configure your Sendbird application to change the order by calling the
sb.setErrorFirstCallback(true). Once true is set, all callbacks pass the error as the first parameter.
sb.setErrorFirstCallback(false) returns callbacks to their original parameter ordering, with errors last.
If you are using the Immutable-js in your web app, instead of the
Immutable.Map(), call the
Immutable.fromJS() which converts deeply nested objects to an
So you can call the functions of Sendbird objects because the
fromJS() method returns internal objects. But if you use a
Map function, you can't call any functions of a Sendbird object.