With CONTUS MirrorFly Chat SDK for Android, you can efficiently integrate the desired real-time chat features into a client app.
When it comes to the client-side implementation, you can initialize and configure the chat with minimal efforts. With the server-side, MirrorFly ensures reliable infra-management services for the chat within the app. This page will let you know how to install the chat SDK in your app.
Note : If you're looking for the fastest way in action with CONTUS MirrorFly Chat SDKs, then you need to build your app on top of our sample version. Simply download the sample app and commence your app development. To download sample app click here
The requirements for chat SDK for Android are:
- Android Lollipop 5.0 (API Level 21) or above
- Java 7 or higher
- Gradle 4.1.0 or higher
Before integrating CONTUS MirrorFly Chat SDK, you need to have a SDK license key for your MirrorFly application. This SDK needs to be authenticated by the MirrorFly server using the license key for further processing.
Step 1: Let’s Create an Account - Sign up into MirrorFly Console page (https://console.mirrorfly.com/register) for free MirrorFly account
Step 2: Create an account with your basic details including your name, organization details, work email, and contact number
Step 3: Once you’re in! You get access to your MirrorFly account ‘Overview page’ where you can find a license key as well as downloadable Android SDK for further integration process
Step 4: You can copy the license key from the ‘Application info’ section
Step 5: To download the AAR files from the Android SDKs, click on ‘Download’ which will take you to the top of the guided documentation page, here, click on the ‘Download button’ and extract the AAR files from the ZIP folder
Step 6: Once finished with the download, now it's time to start with the integration process that begins with creating a new project to develop a chat app.
As soon as the AAR files have been imported from the zip file using Kotlin, you can start over with the integration process.
Step 1: Create a new project or Open an existing project in Android Studio
Step 2: Add the following libraries in app/libs folder in the project
Step 3: Add the below code in the app/build.gradle file.
Step 4: Add the following dependencies in the app/build.gradle file.
Step 5: Add the below dependencies required by the SDK in the app/build.gradle file.
Step 6: Add the below line in the gradle.properties file, to avoid imported library conflicts.
Step 7: Open the AndroidManifest.xml and add below permissions.
To start using the sdk, there is a need for some basic requirements before proceeding with the initialization process. Thus, the ChatSDK builder class is used to provide the necessary data to the SDK. In your
Application class, inside the onCreate() method use the below ChatSDK Builder to provide the necessary data.
|setDomainBaseUrl||Url is provided to make API calls|
|setLicenseKey||License key is required to proceed with registration|
|setIsTrialLicenceKey||If the provided license key is for trial version, display the text as ‘true’ else ‘false’|
|build||n/a||Initializes the chat configuration|
The base URL must have the Http/Https protocol which must be closed with a ‘slash (/)’, if not an exception - a bug message will pop up.
The below method to register a user in sandbox Live mode based on
Unless you log out the session, make a note that should never call the registration method more than once in an application
Note: While registration, the below
registerUsermethod will accept the
FCM_TOKENas an optional param and pass it across.
|USER_IDENTIFIER||A unique Id to Register the User|
|FCM_TOKEN||A registration token that is generated by FCM SDK for the user's app instance to send message for free|
|CALLBACK||FlyCallback is used as a callback, implemented and expressed as lambda expression for easy reading|
In order to send messages using the Chat SDK, at first you need to establish the connection to the server. SDK provides methods for initialize the chat connection.
Note: The ChatManager.connect() method should be called only once in an application. SDK will handle the chat server connection and disconnection automatically.
|CALLBACK||callback listener for chat connection|
Some of the most common terminologies used in Chat SDK with description
|userID/userBareID||Unique ID assigned for each user Ex: 12345678 (any alphanumeric). The below characters is not allowed in userId: U+0022 (") U+0026 (&) U+0027 (') U+002F (/) U+003A (:) U+003C (<) U+003E (>) U+0040 (@) userID should follow below specification: https://xmpp.org/extensions/xep-0106.html|
|userJid (or) JID||userID+@+domain of the chat server Ex. email@example.com|
|groupID/groupBareID||Unique ID assigned for each group Ex: group123456 (any alphanumeric). GroupJID = groupID +@mix.+domain of the chat server Ex: firstname.lastname@example.org`|
SDK will have built-in functions to prepare the JID, Group JID, and more.
Use the below method to send a text message to other user,
Note: To generate a unique user id, you must call the other user's
String userJID = FlyUtils.getJid(USERNAME)
|TO_JID||String||JID of the end user|
|TEXT||String||Indicates the text message that needs to be sent|
|REPLY_MESSAGE_ID||String||Specifies the Message ID of replied message|
|CALLBACK||callback to observe the action status|
You can extend the
FlyBaseActivity from SDK into your app
BaseActivity, and observe all the incoming messages and other feature listeners.
Moreover, here the listeners would be called only when a new message is received from other user. To get more details please visit this callback listeners