Learn how to install QuickBlox SDK and send your first message.
QuickBlox SDK helps you implement a real-time chat, video chat, and push notifications to your app. You can fully concentrate on your mobile app development. QuickBlox Android SDK supports both Java and Kotlin programming languages.
If you are just starting your app and developing it from scratch, we recommend to use our sample apps. 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.
Choose the code sample below to jump-start the development.
Choose the code sample below to jump-start the development.
For more samples, head to our Code Samples page. These sample apps are available on GitHub so feel free to browse them there. Just clone the repository and modify the source code for your own projects.
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:
The minimum requirements for QuickBlox Android SDK are:
To connect QuickBlox SDK to your app, import QuickBlox SDK dependencies via build.gradle file.
Include reference to SDK repository in your project-level build.gradle file at the root directory. Specify the URL of QuickBlox repository where the files are stored. Following this URL gradle finds SDK artifacts.
When the artifacts are found in QuickBlox repository, they get imported to particular SDK modules in build.gradle project file. Add the following code lines to app-level build.gradle file.
Initialize the SDK with your application credentials. Pass the APPLICATION_ID
, AUTH_KEY
, AUTH_SECRET
, and ACCOUNT_KEY
to the init()
method.
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.
Now, it is time to log in with the user. To get it done, set the login and password of the user
, call the signIn()
method, and pass the user
to it using the code snippet below.
Having authorized a user, you can proceed with connecting to the chat server to start using Chat module functionality. Call the login()
method to connect to the chat server.
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. Set the type and occupants IDs of the dialog
using the the setType()
and setOccupantsIds()
methods. Then, call the createChatDialog()
method and pass the dialog
to it.
Through QBDialogMessageListener
you can monitor whether an incoming message or error is received from QuickBlox server. Use QBIncomingMessagesManager
to listen to all incoming messages and related errors.
To send a message, create QBChatMessage
instance and set a text message using the setBody()
method. Then, call the sendMessage()
method.
Set the saveToHistory
parameter if you want this message to be saved in the chat history.
Learn how to install QuickBlox SDK and send your first message.
QuickBlox SDK helps you implement a real-time chat, video chat, and push notifications to your app. You can fully concentrate on your mobile app development. QuickBlox Android SDK supports both Java and Kotlin programming languages.
If you are just starting your app and developing it from scratch, we recommend to use our sample apps. 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.
Choose the code sample below to jump-start the development.
Choose the code sample below to jump-start the development.
For more samples, head to our Code Samples page. These sample apps are available on GitHub so feel free to browse them there. Just clone the repository and modify the source code for your own projects.
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:
The minimum requirements for QuickBlox Android SDK are:
To connect QuickBlox SDK to your app, import QuickBlox SDK dependencies via build.gradle file.
Include reference to SDK repository in your project-level build.gradle file at the root directory. Specify the URL of QuickBlox repository where the files are stored. Following this URL gradle finds SDK artifacts.
When the artifacts are found in QuickBlox repository, they get imported to particular SDK modules in build.gradle project file. Add the following code lines to app-level build.gradle file.
Initialize the SDK with your application credentials. Pass the APPLICATION_ID
, AUTH_KEY
, AUTH_SECRET
, and ACCOUNT_KEY
to the init()
method.
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.
Now, it is time to log in with the user. To get it done, set the login and password of the user
, call the signIn()
method, and pass the user
to it using the code snippet below.
Having authorized a user, you can proceed with connecting to the chat server to start using Chat module functionality. Call the login()
method to connect to the chat server.
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. Set the type and occupants IDs of the dialog
using the the setType()
and setOccupantsIds()
methods. Then, call the createChatDialog()
method and pass the dialog
to it.
Through QBDialogMessageListener
you can monitor whether an incoming message or error is received from QuickBlox server. Use QBIncomingMessagesManager
to listen to all incoming messages and related errors.
To send a message, create QBChatMessage
instance and set a text message using the setBody()
method. Then, call the sendMessage()
method.
Set the saveToHistory
parameter if you want this message to be saved in the chat history.