Let's integrate our UIKIT in few minutes

Download#

Download UIKit SDK
Download

SDK UIKit for Android#

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.

Requirements#

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.

Follow the below steps to get your license key:

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: 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 5: 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.

Integration#

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

  • appbase.aar
  • flycommons.aar
  • flynetwork.aar
  • flydatabase.aar
  • videocompression.aar
  • xmpp.aar
  • mfuikitsdk.aar
  • flycall.aar
  • flywebrtc.aar
  • cameraview.aar
  • zoomimageview.aar
  • mediapicker.aar
  • imagecropper.aar
  • googletranslation.aar

Aarfiles

Step 3: 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/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LGPL2.1'
exclude("META-INF/*.kotlin_module")
}
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 4: Add the below code in the settings.gradle file.

pluginManagement {
repositories {
gradlePluginPortal()
google()
jcenter()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
jcenter()
}
}

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

dependencies {
... // your app dependencies
implementation files('libs/appbase.aar')
implementation files('libs/flycommons.aar')
implementation files('libs/flynetwork.aar')
implementation files('libs/flydatabase.aar')
implementation files('libs/videocompression.aar')
implementation files('libs/xmpp.aar')
implementation files('libs/mfuikitsdk.aar')
implementation files('libs/flycall.aar')
implementation files('libs/flywebrtc.aar')
implementation files('libs/cameraview.aar')
implementation files('libs/zoomimageview.aar')
implementation files('libs/mediapicker.aar')
implementation files('libs/imagecropper.aar')
implementation files('libs/googletranslation.aar')
}

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

dependencies {
configurations {
all {
exclude group: 'org.json', module: 'json'
exclude group: 'xpp3', module: 'xpp3'
}
}
//For lifecycle listener
implementation 'android.arch.lifecycle:extensions:1.1.1'
annotationProcessor 'android.arch.lifecycle:compiler:1.1.1'
//KTX Depenedency
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.0'
//For GreenDao
implementation 'de.greenrobot:greendao:2.1.0'
//For gson parsing
implementation 'com.google.code.gson:gson:2.8.6'
//room database
implementation 'androidx.room:room-runtime:2.4.2'
kapt 'androidx.room:room-compiler:2.4.2'
implementation "androidx.room:room-ktx:2.4.2"
//Emoji
implementation 'androidx.emoji:emoji:1.1.0'
implementation 'androidx.emoji:emoji-appcompat:1.1.0'
implementation 'io.github.rockerhieu:emojicon:1.4.2'
//Socket - versions.gradle
implementation 'com.github.nkzawa:socket.io-client:0.6.0'
//for webrtc
implementation 'org.webrtc:google-webrtc:1.0.32006'
//for smack implementation
implementation ('org.igniterealtime.smack:smack-android:4.4.6')
implementation ('org.igniterealtime.smack:smack-tcp:4.4.6')
implementation 'org.igniterealtime.smack:smack-im:4.4.6'
implementation 'org.igniterealtime.smack:smack-extensions:4.4.6'
implementation 'org.igniterealtime.smack:smack-sasl-provided:4.4.6'
//for mobile number formatting
implementation 'io.michaelrocks:libphonenumber-android:8.12.43'
//Dagger Dependencies
api 'com.google.dagger:dagger:2.40.5'
annotationProcessor 'com.google.dagger:dagger-compiler:2.27'
api 'com.google.dagger:dagger-android:2.40.5'
api 'com.google.dagger:dagger-android-support:2.40.5'
kapt 'com.google.dagger:dagger-android-processor:2.27'
//coroutines
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.8'
//apicalls
implementation 'com.squareup.retrofit2:retrofit:2.6.1'
implementation 'com.squareup.retrofit2:converter-gson:2.6.1'
implementation 'com.squareup.okhttp3:okhttp:4.2.0'
implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2'
//stetho interceptor
implementation 'com.facebook.stetho:stetho-okhttp3:1.3.1'
//okhttp interceptor
implementation 'com.squareup.okhttp3:logging-interceptor:3.14.3'
// Glide
implementation 'com.github.bumptech.glide:glide:4.11.0'
implementation 'com.github.bumptech.glide:okhttp3-integration:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
implementation 'com.github.bumptech.glide:annotations:4.11.0'
// security:security-crypto
implementation 'androidx.security:security-crypto:1.1.0-alpha03'
//
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
implementation "androidx.paging:paging-runtime-ktx:3.1.0-alpha01"
//
implementation 'com.jakewharton.rxbinding3:rxbinding:3.1.0'
implementation 'com.jakewharton.rxbinding3:rxbinding-core:3.1.0'
implementation 'com.jakewharton.rxbinding3:rxbinding-appcompat:3.1.0'
implementation 'com.jakewharton.rxbinding3:rxbinding-material:3.1.0'
implementation 'com.jakewharton.rxbinding3:rxbinding-recyclerview:3.1.0'
//Collapsing Toolbar
implementation 'net.opacapp:multiline-collapsingtoolbar:27.1.1'
}

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

buildscript {
dependencies {
def nav_version = "2.3.5"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
}
}

Step 8: Add the below line in the gradle.properties file, to avoid imported library conflicts.

android.enableJetifier=true

Step 9: Open the AndroidManifest.xml and add below permissions.

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

Initialization#

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.

Then provide your APP_NAME BASE_URL LICENCE_KEY isCallEnabled = false and If you have subscription set isTrialLicenceKey true else set isTrialLicenceKey false

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

package com.example.mfuikittest
import android.app.Application
import com.mirrorflyuikitsdk.MirrorFlyUIKit
import com.mirrorflyuikitsdk.adapter.MirrorFlyUIKitAdapter
class BaseApplication : Application() {
override fun onCreate() {
super.onCreate()
ChatManager.startActivity = StartActivity::class.java // Chat Notification click to redirect
MirrorFlyUIKit.callSDKNotificationClass = MainActivity::class.java(User defined Activity) // Call Notification click to redirect
MirrorFlyUIKit.isContactEnable = true // To enable the contact screen
MirrorFlyUIKit.isOtherProfileEnable = true // To enable the other profile screen
MirrorFlyUIKit.isOwnProfileEnable = true // To enable the own profile screen
MirrorFlyUIKit.isGroupEnable = true // To enable the group screen
MirrorFlyUIKit.isCallEnabled = true // To enable the call feature
MirrorFlyUIKit.defaultThemeMode = MirrorFlyUIKit.ThemeMode.Light // To set the Theme
MirrorFlyUIKit.initFlySDK(applicationContext,object : MirrorFlyUIKitAdapter {
override fun setApplicationID(): String? {
return "YOUR_APPLICATION_ID"
}
override fun setAppName(): String? {
return "YOUR_APP_NAME"
}
override fun setBaseUrl(): String {
return "YOUR_BASE_URL"
}
override fun setLicence(): String {
return "YOUR_LICENCE_KEY"
}
override fun isTrialLicenceKey(): Boolean? {
return true
}
})
}
}
ArgumentTypeDescription
YOUR_APP_NAMEStringset your application name
YOUR_APPLICATION_IDStringset your application id
YOUR_BASE_URLStringset your base url
YOUR_LICENCE_KEYStringset your licence key
YOUR_GOOGLE_TRANSLATION_KEYStringset your Translation key
isTrialLicenceKeyBooleanset true or false
isContactEnableBooleanset true or false
isCallEnabledBooleanset true or false
isGroupEnableBooleanset true or false
isOwnProfileEnableBooleanset true or false
isOtherProfileEnableBooleanset true or false

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"
package="com.example.uikitapplication">
<application
android:name=".BaseApplication" // Add this line.
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
...
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

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

Registration#

The below method to register a user.

info

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("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")
}
}
})
ArgumentTypeDescription
USER_IDENTIFIERStringUnique Id to Register the User
FIREBASE TOKENStringFirebase Token for Message and Call Push Notification

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?) {
super.onCreate(savedInstanceState)
// 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#

recent_single_chat_light