In order to use the features of the Chat SDK in your client apps, a
SendBird instance should be initiated in each client app through user authentication with Sendbird server. The instance communicates and interacts with the server using an authenticated user account, and is allowed to use the Chat SDK's features. This page explains how to authenticate your user with the server.
To use our chat features, you should initialize a
SendBirdClient instance by passing the APP_ID of your Sendbird application to the
SendBirdClient.Init() must be called once across your client app. Typically, initialization is implemented in the user login screen.
By default, Sendbird server can authenticate a user just by a unique user ID. Then the server queries the database to check for a match upon the request for connection. If no matching user ID is found, the server creates a new user account with the user ID. The ID should be unique within a Sendbird application to be distinguished from others, such as a hashed email address or phone number in your service.
This authentication procedure is useful when you are in development or if your service doesn't require additional security.
Note: Go to the Event handler page to learn more about the usages of the Chat SDK's handlers and callbacks.
Using Chat Platform API, you can create a user along with their own access token, or issue an access token for an existing user. Once an access token is issued, a user is required to provide the access token in the
SendBirdClient.connect() method which is used for signing in.
- Using the Chat API, create a Sendbird user account with the information submitted when a user signs up or in to your service.
- Save the user ID along with the issued access token to your persistent storage which is securely managed.
- When the user attempts to sign in to the Sendbird application, load the user ID and access token from the storage, and then pass them to the
- For security, we recommend updating the user's access token periodically by issuing a new token to replace.
Note: You are able to prevent users without an access token from signing in to the application or restrict their access to read and write messages in your dashboard: Settings > Application > Security > Access Token Policy.
You must disconnect from Sendbird server when your user no longer needs to receive messages from an online state. But users would receive push notifications for new messages from their group channels.
When disconnected from the server, all registered handlers and callbacks are removed. That means, it removes all event handlers added through the
SendBirdClient.AddConnectionHandler(). It also flushes all internally cached data, such as the cached channels from calling the
Note: By default, most of the data related to users, channels, and messages are internally cached in the
SendBirdinstance of a user's client app, which are retrieved by the corresponding query instances or received through the event handlers.
updateCurrentUserInfo() method, you can update a user's nickname and profile image, as well as their profile picture with a URL.
Or, you can upload an image directly using the