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 by clicking the New app button.
- Configure the app. Type in the information about your organization into corresponding fields and click the Add button.
- Go to the Dashboard => YOUR_APP => Overview section and copy your Application ID, Authorization Key, Authorization Secret, and Account Key .
Requirements
The minimum requirements for QuickBlox Android SDK are:- Android 5.0 (API 21)
- Android Studio
- Gradle 4.6
- Gradle plugin 2.5.1
Install QuickBlox SDK into your app
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.Groovy
Groovy
Parameters | Description |
---|---|
messages | Push Notifications module enables working with push notifications and alerts to users. |
chat | Chat module allows creating dialogs and sending messages into these dialogs. |
content | Content module enables file storage and creating chat attachments for your app. |
webrtc | Video Calling module adds video and audio calling features to your app. |
conference | Video Conference allows setting up a video conference between 10-12 people in your app. |
customobjects | Custom Objects module provides flexibility to define any data structure you need for your app. |
Add permissions
To use the QuickBlox SDK, you need to add the following permissions to your app manifest:XML
XML
XML
Note that mentioning the camera and microphone permissions in the manifest isn’t always enough. You need to request camera and microphone permissions additionally at runtime.
Initialize QuickBlox SDK
Initialize the framework with your application credentials. Pass Application ID, Authorization Key, Authorization Secret, and Account Key to theinit()
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.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.
Argument | Required | Description |
---|---|---|
APPLICATION_ID | yes | Application identifier. |
AUTH_KEY | yes | Authorization key. |
AUTH_SECRET | yes | Authorization secret. |
ACCOUNT_KEY | yes | Account key. Required to get actual Chat and API endpoints for the right server. |
Initialize QuickBlox SDK without Authorization Key and Secret
You may don’t want to store authKey and authSecret inside an application for security reasons. In such case, you can initialize QuickBlox SDK with applicationId and accountKey only, and store your authKey and authSecret on your backend. But, if so, the implementation of authentication with QuickBlox should be also moved to your backend.QBAuth.startSessionWithToken()
method. You can find out more about this in the [Set existing session](/sdks/android-authentication #set-existing-session) section.
Point SDK to the enterprise server
To point QuickBlox SDK to the QuickBlox enterprise server, you should pass theAPI_ENDPOINT
and CHAT_ENDPOINT
to the setEndpoints()
method. You can call this method only after initializing the SDK.
Argument | Required | Description |
---|---|---|
API_ENDPOINT | yes | API endpoint. |
CHAT_ENDPOINT | yes | Chat endpoint. |
serviceZone | yes | Connection service zone. The area where push notifications and messages can work. |
Contact our sales team to get API endpoint and chat endpoint.
Enable logging
Logging functionality allows you to keep track of all events and activities while running your app. As a result, you can monitor the operation of the SDK and improve the debug efficiency. There are 3 logging use cases:- Server API logging is used to monitor Server API calls.
- Chat logging is used to monitor chat issues.
- WebRTC logging is used to gather issues with video.
Parameters | Description |
---|---|
LogLevel.NOTHING | Write nothing. Turn off logs. |
LogLevel.DEBUG | Enable logs (default value). |
true
is enabled, false
is disabled. Default: false
.
setDebugEnabled()
method. true
is enabled, false
is disabled. Default: true.
Enable auto-reconnect to Chat
QuickBlox Chat runs over XMPP protocol. To receive messages in a real-time mode, the application should be connected to the Chat over XMPP protocol. To enable auto-reconnect to Chat, call thesetReconnectionAllowed()
method and pass true
.
By default, autoreconnection functionality is enabled. Set autoreconnection before calling the
QBChatService.getInstance().login()
method so it could be applied in a current chat.Message carbons
Message carbons functionality allows for multi-device support. Thus, all user messages get copied to all their devices so they could keep up with the current state of the conversation. For example, a User A has phone running conversations and desktop running conversations. User B has desktop running conversations. When User B sends a message to User A, the message shows on both the desktop and phone of User A. Enable message carbonsBy default, message carbons functionality is disabled.
Since message carbons functionality works over XMPP connection, make sure to enable it after the
QBChatService.getInstance().login()
method is called.Stream management
Stream management has two important features Stanza Acknowledgements and Stream Resumption:- Stanza Acknowledgements is the ability to know if a stanza or series of stanzas has been received by one’s peer. In other words, a reply is requested on every sent message. If the reply is received, the message is considered as delivered.
- Stream Resumption is the ability to quickly resume a stream that has been terminated. Once a connection is re-established, Stream Resumption is executed. By matching the sequence numbers assigned to each Stanza Acknowledgement a server and client can verify which messages are missing and request to resend missing messages.
By default, stream management functionality is disabled.
You should enable Stream Management before you do the
login()
because the Stream Management is initialized while Chat login is performed.The Stream Management defines an extension for active management of a stream between a client and server, including features for stanza acknowledgments.Configure media settings
You can use aQBRTCMediaConfig
class instance to configure a various list of media settings like video/audio codecs, bitrate, fps, etc.
Make sure to setup media settings before initiating a call.
Synchronous and Asynchronous performers
You can use different performersperform()
or performAsync()
. Please note that the QBUsers.getUser()
method is used there as an example. You can use these performers in all cases where performers are available. In a synchronous way, you should handle QBResponseException
.