Let's integrate our UIKIT in few minutes

Mirrorfly UIKit Sdk is a set of prebuilt UI components that allows you to easily integrate an in-app chat with all the essential messaging features. Our development kit includes light and dark themes, text fonts, colors and more. You can customize these components to create an interactive messaging unique interface.


The requirements for chat SDK for Android are:

  • Android Marshmallow 6.0 (API Level 23) or above
  • Java 8 or higher
  • Gradle 4.1.0 or higher

Things to be Noted Before Making a Start#

SDK License Key#

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.

To get the License Key,#

Step 1: Register here to get a MirrorFly User account. Registration is subject to verification and would take up to 24 hours.

Step 2: Login to your Account

Step 3: Get the License key from the application Info’ section



Step 1: Create a new project or Open an existing project in Android Studio

Step 2: Add the below code in the app/build.gradle file.

plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-android'
id 'kotlin-kapt'
id 'kotlin-android-extensions'
id 'androidx.navigation.safeargs'
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
kotlinOptions {
jvmTarget = '1.8'
packagingOptions {
exclude 'META-INF/AL2.0'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LGPL2.1'
buildFeatures {
viewBinding = true
dataBinding {
enabled = true

Note : In case "The 'kotlin-android-extensions' Gradle plugin is no longer supported" then remove the 'kotlin-android-extensions' from app/build.gradle plugins".

Step 3: If using Gradle 6.8 or higher, add the following code to your settings.gradle file. If using Gradle 6.7 or lower, add the following code to your root build.gradle file. See this release note to learn more about updates to Gradle.

dependencyResolutionManagement {
repositories {
maven {
url "https://repo.mirrorfly.com/release"

Step 4: Add the following dependencies in the app/build.gradle file.

dependencies {
implementation 'com.mirrorfly.uikitsdk:mf-uikitsdk:1.0.24'

Step 5: Add the below dependencies required by the SDK in the app module/build.gradle file.

buildscript {
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21'
dependencies {
def nav_version = "2.3.5"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"

Note : Use 'kotlin-gradle-plugin' version '1.6.21' and above.

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.

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />


To integrate and run Mirrorfly UIKit in your app, you need to initialize it first. You can initialize the MirrorFlyUIKit instance by passing the MirrorFlyUIKitAdapter instance as an argument to a parameter in the MirrorFlyUIKit.init() method. The MirrorFlyUIKit.init() must be called once in the onCreate() method of your app’s Application instance.

Step 1: Add the below line in the application class file.

Then provide your APP_NAMEand APPLICATION_ID to setup your application

This isCallEnabled isGroupEnable isContactEnable isLogoutEnable isOtherProfileEnable isOwnProfileEnable setGoogleTranslationKey and onlyOnetoOneChat methods are optional used to customize application.

package com.example.mfuikittest
import android.app.Application
import com.mirrorflyuikitsdk.MirrorFlyUIKit
import com.mirrorflyuikitsdk.adapter.MirrorFlyUIKitAdapter
class BaseApplication : Application() {
override fun onCreate() {
MirrorFlyUIKit.initFlySDK(applicationContext,object : MirrorFlyUIKitAdapter {
override fun setAppName(): String? {
return "YOUR_APP_NAME"
override fun setApplicationID(): String? {
//Below override methods are optional used for customization
override fun isCallEnabled(): Boolean? {
return true
override fun isGroupEnable(): Boolean? {
return true
override fun isContactEnable(): Boolean? {
return true
override fun isLogoutEnable(): Boolean? {
return true
override fun isOtherProfileEnable(): Boolean? {
return true
override fun isOwnProfileEnable(): Boolean? {
return true
override fun setGoogleTranslationKey(): String? {
override fun onlyOnetoOneChat(): Boolean? {
return false
MirrorFlyUIKit.defaultThemeMode = MirrorFlyUIKit.ThemeMode.Light
MirrorFlyUIKit.loginActivity = "LoginActivity"::class.java
YOUR_APP_NAMEStringset your application name
YOUR_APPLICATION_IDStringset your application id
onlyOnetoOneChatBooleanset true or false
isLogoutEnableBooleanset true or false
setGoogleTranslationKeyStringset your Translation key
isContactEnableBooleanset true or false
isCallEnabledBooleanset true or false
isGroupEnableBooleanset true or false
isOwnProfileEnableBooleanset true or false
isOtherProfileEnableBooleanset true or false
loginActivityClass<*>set LoginActivity used in your application to redirect to login while user logout application

Step 2: Add the below line in the Launcher class file.

This LICENCE_KEY can be obtained from 'Overview' section from the Console dashboard.

class SplashTestActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
MirrorFlyUIKit.initializeSDK(activity,"SplashActivity"::class.java,"YOUR_LICENCE_KEY",object : FlyInitializeSDKCallback{
override fun flyError(
isSuccess: Boolean,
throwable: Throwable?,
data: HashMap<String, Any>
) {
//TODO Error Handling
override fun redirectToDashBoard(isSuccess: Boolean)
//Redirect to DashBoard
override fun redirectToLogin(isSuccess: Boolean)
//Redirect to Login Screen
YOUR_LICENCE_KEYStringset your licence key
redirectToDashBoardfunSDK Configuration callback to redirect dashboard
redirectToLoginfunSDK Configuration callback to redirect login screen
flyErrorfunSDK Configuration callback for error handling
SplashActivityClass<*>set your SplashActivity while licence expire it redirect to splash for configuration

Add BaseApplication#

Add the created BaseApplication to AndroidManifest.xml.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:name=".BaseApplication" // Add this line.
<activity android:name=".MainActivity">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />

Note : Use the "Theme.MaterialComponents.DayNight.NoActionBar" in the style.xml or themes.xml to avoid the app bar in the call screen.


The below method to register a user.


Unless you log out the session, make a note that should never call the registration method more than once in an application.

Note : Use the Mirrorfly UIKIt SDK registration function after your application login process.

MirrorFlyUIKit.initUser(activity,"USER_IDENTIFIER", "FIREBASE TOKEN", object : InitResultHandler {
override fun onInitResponse(isSuccess: Boolean, e: String) {
if (isSuccess) {
Log.d("TAG", "onInitResponse called with: isSuccess = $isSuccess")
} else {
Log.e("TAG", "onInitResponse called with: Failure, e = $e")
USER_IDENTIFIERStringA Unique Id to Register the User. We accept only the AlphaNumeric String
FIREBASE TOKENStringFirebase Token for Message and Call Push Notification

Note : 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

Display Recent Chat and Call list#

DashBoardActivity is the starting point for launching UIKit in your application. By implementing the code below, you will see a complete list of recent chats that you're made with single and group conversation.

Note : Use DashBoardActivity only when you have done the registration.

package com.custom.mfuikittest
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.mirrorflyuikitsdk.activities.DashBoardActivity
class MainActivity : DashBoardActivity() { // Add this line.
override fun onCreate(savedInstanceState: Bundle?) {
// If you’re going to inherit `DashBoardActivity`, don’t implement `setContentView()`

Sending a message#

You can now run the application on an emulator or a plugged-in device. To send a message, you must first start a conversation by clicking on the icon in the top-right corner. Then, you can select the user you wish to chat. Once navigated to user chat screen, type your first message and press send.

Recent & Single Chat#