How To Create A Custom Instant Messaging App (Guess What, I Launched It In 48 Hrs)

Have a plan to build your own white label instant messaging software? That’s great. I also had the same thought.
For the last 4 years, I worked on many IT projects. Usually, the time for product development from scratch takes at least 6 months.
However, I noticed the demand for a low-code platform is growing fast.
So, I spend day and night researching the right solution for building the IM software.
100% Customizable Workflow
Integrate Across Android, IOS & Web
Support Hosting On Any Server
Allow Third-Party Integration
Production-Ready Solution
Full Branding Control Over UI
Easy To Develop & Launch
Offer Full Source Code Access
Proper Documentation
End-To-End Encryption
And, I came across a self-hosted solution, MirrorFly.
It helped me build and deploy a secure instant messaging solution within 48 hours.
To explain the build process, I have divided it into four phases.
Phase 1: Download the SDK solution
Phase 2: Integrate chat SDK into your app
Phase 3: Add advanced features
Phase 4: Launch the app
Now, let's look into them one by one.
Contact the MirrorFly team to create your user account.
After this, from the MirrorFly console page, you can find the license key. This unique key is required for authenticating the SDK in your app project.
Now, let’s integrate the MirrorFly chat SDK into the project codebase.
As a prerequisite, you’ll need:
Android Lollipop 5.0 (API Level 21) or above
Java 7 or higher
Gradle 8.6.0 or higher
Kotlin 2.0.20 or higher
targetSdkVersion,compileSdk 35
In this phase, a total of ten steps are involved.
Step 1: Create a new project or open an existing project in Android Studio.
Step 2: To inform Gradle where to download the chat SDK and its dependencies, add the code.
For Gradle 6.8 or higher, add the following code to your settings.gradle file.
dependencyResolutionManagement {
repositories {
mavenCentral()
google()
jcenter()
maven {
url "https://repo.mirrorfly.com/release"
}
}
}
For Gradle 6.7 or lower, add the following code to your root build.gradle file.
allprojects {
repositories {
mavenCentral()
google()
jcenter()
maven {
url "https://repo.mirrorfly.com/release"
}
}
}Step 3: Add the below dependencies to the app/build.gradle file.
dependencies {
implementation 'com.mirrorfly.sdk:mirrorflysdk:7.13.32'
}Step 4: Add the below line in the gradle.properties file, to avoid imported library conflicts.
android.enableJetifier=trueStep 5: Open the AndroidManifest.xml and add below permissions.
<uses-permission android:name="android.permission.INTERNET" />Step 6: Next, we have to initialize the MirrorFly SDK.
But the following is a basic requirement before proceeding with the initialization.
In your Application class, inside the onCreate() method, use the below method from ChatManager to provide the necessary data.
Now, to initialize MirrorFly SDK, modify your MyApplication.java (or custom Application class):
ChatManager.initializeSDK("LICENSE_KEY", (isSuccess, throwable, data) -> {
if(isSuccess){
Log.d("TAG", "initializeSDK success ");
}else{
Log.d("TAG", "initializeSDK failed with reason "+data.get("message"));
}
});
Add the created MyApplication 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=".MyApplication" // 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>
Step 7: Now, make the following call to register a user.
FlyCore.registerUser(USER_IDENTIFIER, (isSuccess, throwable, data ) -> {
if(isSuccess) {
Boolean isNewUser = (Boolean) data.get("is_new_user"); // true - if the current user is different from the previous session's logged-in user, false - if the same user is logging in again
String userJid = (String) data.get("userJid"); //Ex. [email protected] (USER_IDENTIFIER+@+domain of the chat server)
JSONObject responseObject = (JSONObject) data.get("data");
String username = responseObject.getString("username");
} else {
// Register user failed print throwable to find the exception details.
}
});
Step 8: At this moment, registration is successful, and a connection is created automatically.
You will receive the connection status in the callback method as mentioned below.
ChatManager.setConnectionListener(new ChatConnectionListener() {
@Override
public void onConnected() {
// Write your success logic here to navigate Profile Page or
// To Start your one-one chat with your friends
}
@Override
public void onDisconnected() {
// Connection disconnected
}
@Override
public void onConnectionFailed(@NonNull FlyException e) {
// Connection Not authorized or Unable to establish connection with server
}
@Override
public void onReconnecting() {
// Automatic reconnection enabled
}
});
Step 9: For sending and receiving messages, you’ll need a JID (Jabber ID).
Use the below method:
String userJid = FlyUtils.getJid(USER_NAME);Step 10: To send a text message to another user, use this method:
TextMessage textMessage = new TextMessage();
textMessage.setToId(TO_JID);
textMessage.setMessageText(TEXT);
FlyMessenger.sendTextMessage(textMessage, (isSuccess, error, chatMessage) -> {
if (isSuccess) {
// you will get the message sent success response
}
});To receive any message on your IM app, set up a listener:
ChatEventsManager.setupMessageEventListener(new MessageEventsListener() {
@Override
public void onMessageReceived(@NotNull ChatMessage message) {
//called when the new message is received
}
});In this stage, your white label IM app will be able to send and receive real-time messages.
Now you can customize the team chat software with 1000+ in-app features based on the business requirement from this pre-built solution.
Follow the MirrorFly documentation to add any advanced features.
That’s it. Now, you can deploy the instant messaging software either on your own premises or on MirrorFly’s cloud servers.
Have any doubts? Comment below!
0
0
0