The QuickBlox Developer Hub

Welcome to the QuickBlox developer hub. You'll find comprehensive guides and documentation to help you start working with QuickBlox as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

Quick Start

This is our new documentation for alpha version of QuickBlox Flutter SDK. Please contact our Customer Support Team to provide your feedback, suggestions, and requests to improve this page.

QuickBlox SDK helps you implement real-time chat, video chat, and push notifications to your app. You can fully concentrate on your mobile app development. Our SDK provides you with many helpful methods to build a chat app with diverse features.

This Quick Start page will help newcomers and even our veteran users familiarize themselves with basic SDK functionalities and logic. It lets you go through the easy steps of implementing QuickBlox in your app.

Create a new app in the Dashboard

QuickBlox application includes everything that brings messaging right into your application - chat, video calling, users, push notifications, etc. To create a QuickBlox application, follow the steps below:

  1. Register a new account following this link. Type in your email and password to sign in. You can also sign in with your Google or Github accounts.
  2. Create the app clicking New app button.
  3. Configure the app. Type in the information about your organization into corresponding fields and click Add button.
  4. Go to Dashboard => Overview => Credentials groupbox and copy your Application ID, Authorization Key, Authorization Secret, and Account Key .

Install QuickBlox SDK into your app

Note

To manage project dependencies the Flutter should be installed.

To connect QuickBlox to your app just add it into your project dependencies in pubspec.yaml file located in the root project directory => dependencies section.

dependencies:
  flutter:
    sdk: flutter

  # The following adds the QuickBlox SDK to your application.
  quickblox_sdk: 0.1.0-alpha

Send your first message

Initialize QuickBlox SDK

Initialize the framework with your application credentials. Pass appId, authKey, authSecret, accountKey to the init() method using the code snippet below. As a result, your application details are stored in the server database and can be subsequently identified on the server.

Pay attention

You must initialize SDK before calling any methods through the SDK, except for the init() method. If you attempt to call a method without connecting, the error is returned.

try {
  await QB.settings.init(
      appId, 
      authKey, 
      authSecret, 
      accountKey,
      apiEndpoint: apiEndpoint, 
      chatEndpoint: chatEndpoint);
} on PlatformException catch (e) {
  // Some error occured, look at the exception message for more details
}

Note

apiEndpoint and chatEndpoint are optional parameters that should set if you're on Enterprise Plan.

Authorize user

In order to use the abilities of QuickBlox SDK, you need to authorize your app on the server, log in to your account and create a session. To get it all done call login() method and pass userLogin and userPassword parameters to it using the code snippet below.

try {
  QBLoginResult result = await QB.auth.login('userLogin', 'userPassword');
  QBUser qbUser = result.qbUser;
  QBSession qbSession = result.qbSession;
} on PlatformException catch (e) {
  // Some error occured, look at the exception message for more details
}

Connect to Chat

To connect to Chat server, use connect() method.

try {
  await QB.chat.connect(userId, userPassword);
} on PlatformException catch (e) {
  // Some error occured, look at the exception message for more details
}

Create dialog

QuickBlox provides three types of dialogs: 1-1 dialog, group dialog, and public dialog. Learn more about dialogs here.

Let’s create 1-1 dialog. Call createDialog() method and pass dialogName and dialogType parameter as a dialog type to it. occupantsIds parameter allows specifying how many occupants are going to participate in the dialog.

try {
  QBDialog createdDialog = await QB.chat.createDialog(
      occupantsIds, 	
      dialogName, 
      dialogType: QBChatDialogTypes.PUBLIC_CHAT);
} on PlatformException catch (e) {
  // Some error occured, look at the exception message for more details
}

Note

dialogType is an optional parameter. If this parameter was not set, then public dialog is created by default.

Subscribe to receive messages

QuickBlox provides message event handler allowing to notify client apps of events that happen on the Chat. Thus, when a dialog has been created, a user can subscribe to receive notifications about new incoming messages. To subscribe to message events call subscribeMessageEvents() method to tell SDK to send events about new messages. Pass dialogId, eventName, and event handler to it using the following code snippet. The event handler is called when the SDK receives a new message.

try {
  await QB.chat.subscribeMessageEvents(dialogId, eventName, (data) {
    Map<String, Object> map = new Map<String, dynamic>.from(data);
    String messageType = map["type"];
    String messageBody = "system message";
    if (messageType == QBChatEvents.RECEIVED_NEW_MESSAGE) {
      Map<String, Object> payload =
          new Map<String, dynamic>.from(map["payload"]);
      messageBody = payload["body"];
      messageId = payload["id"];
    }
  });
} on PlatformException catch (e) {
  // Some error occured, look at the exception message for more details
}

Send message

When a dialog is created, a user can send a message. To create and send your first message, call sendMessage() method and specify the dialogId and body parameters to it. Pass saveToHistory parameter if you want this message to be saved in chat history that is stored forever.

try {
  await QB.chat.sendMessage(
      dialogId,
      body: "hey there !",
      attachments: attachments,
      properties: properties,
      markable: true,
      dateSent: date,
      saveToHistory: true);
} on PlatformException catch (e) {
  // Some error occured, look at the exception message for more details
}

Note

body, attachments, properties, markable, dateSent, and saveToHistory are optional parameters.

Updated 10 days ago


What's Next

Setup

Quick Start


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.