Quick Start
Learn how to install QuickBlox SDK and send your first message.
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.
Start with sample app
Choose the code sample below to jump-start the development. We use GitHub repositories to make it easy to explore, copy, and modify our code samples. The guide on how to launch and configure the sample app is on GitHub.
Flutter Chat Sample App
Flutter Chat Sample App
For more samples, head to our Code Samples page. These sample apps are available on GitHub so feel free to browse them there.
Get application credentials
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:
- 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.
- Create the app clicking New app button.
- Configure the app. Type in the information about your organization into corresponding fields and click Add button.
- Go to Dashboard => YOUR_APP => Overview section and copy your Application ID, Authorization Key, Authorization Secret, and Account Key .
Requirements
The minimum requirements for QuickBlox Flutter SDK are:
- iOS 13.0
- Android (minimum version 5.0, API 21)
- Flutter (minimum version 2.12.0)
Install QuickBlox SDK into your app
To manage project dependencies 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.
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.
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.
Security
It’s not recommended to keep your authKey and authSecret inside an application in production mode, instead of this, the best approach will be to store them on your backend and initialize QuickBlox SDK with applicationId and acountKey only. More details you can find in Initialize QuickBlox SDK without Authorization Key and Secret section.
Authorize user
Now, it is time to log in with the user. To get it done, set the login and password of the user, call the login()
method and pass the login
and password
to it using the code snippet below.
Connect to chat
Having authorized a user, you can proceed with connecting to the chat server to start using Chat module functionality. Call the the connect()
method and pass userId
and password
to it.
Create dialog
QuickBlox provides three types of dialogs: 1-1 dialog, group dialog, and public dialog. Learn more about dialogs here.
Let’s create a simple 1-1 dialog. Call the createDialog()
method and pass the occupantsIds
, dialogName
, and dialogType
to it.
Subscribe to receive messages
QuickBlox SDK emits events to notify about chat events. Thus, when a message has been received, a user receives the event from SDK about a new incoming message. To process events, you need to provide an event handler that SDK will call. See the code snippet below.
Send message
To send a message, call the sendMessage()
method and pass the dialogId
and body
as arguments to it.
Set the saveToHistory
parameter if you want this message to be saved in chat history.
Was this page helpful?