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
View on GitHub Documentation 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.
YAML
⚠️ Android – Breaking Change (from 0.18.0 and above)
Starting from 0.18.0, the SDK no longer manages permissions required for calling functionality on Android. If your app uses calling features, you must manually declare the necessary permissions in your app’sAndroidManifest.xml
file.
Kindly ensure you’re modifying the main
AndroidManifest.xml
file located at the application level — not a test or variant manifest.XML
Send your first message
Initialize QuickBlox SDK
Initialize the framework with your application credentials. PassappId
, authKey
, authSecret
, accountKey
to the init()
method using the code snippet below.
Dart
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.SecurityIt’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 thelogin()
method and pass the login
and password
to it using the code snippet below.
Dart
Connect to chat
Having authorized a user, you can proceed with connecting to the chat server to start using Chat module functionality. Call theconnect()
method and pass userId
and password
to it.
Dart
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 thecreateDialog()
method and pass the occupantsIds
, dialogName
, and dialogType
to it.
Dart
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.Dart
Send message
To send a message, call thesendMessage()
method and pass the dialogId
and body
as arguments to it.
Dart
Set the
saveToHistory
parameter if you want this message to be saved in chat history.