Skip to main content

Before you begin

  1. Register a QuickBlox account. This is a matter of a few minutes and you will be able to use this account to build your apps.
  2. Configure QuickBlox SDK for your app. Check out Setup page for more details.
  3. Create a user session to be able to use QuickBlox functionality. See Authentication page to learn how to do it.
Visit Key Concepts page to learn the most important QuickBlox concepts.

Connect to Chat server

To connect to Chat server use the code snippet below.
JavaScript

Subscribe to connection state

Subscribe to the connection state changes using the following code snippet.
JavaScript

Check if connected to Chat server

Check the connection state using the following code snippet.
JavaScript

Check if connected to Chat server

Check the connection state using the following code snippet.

Disconnect from Chat server

Disconnect from the Chat server using the snippet below.
JavaScript

Enable auto-reconnect to Chat

The SDK reconnects automatically when the connection to the Chat server is lost. There is a way to disable it and then manage it manually.
JavaScript

Manage Chat connections

To provide a seamless chat experience, our SDK manages connections to the Chat server at an application-wide level. Thus, to handle offline messages correctly, use the disconnect() method when an app goes to the background and connect() method when an app goes to the foreground. As a result, the SDK will disconnect/connect the current user from the Chat server when the app goes to the background/foreground mode.
JavaScript