Let's integrate our SDK in few minutes

Quick Start#

Meet SDK for Android#

With CONTUS MirrorFly Meet SDK for Android, you can easily add real-time meet features to your client app within 30 minutes.

Through our client SDK, you can initialize and configure meet into your app with minimal efforts.

Note : If you're looking for the fastest way to build your appโ€™s UI with MirrorFly Meet SDKs, you can use our sample apps. To get our sample apps, click here

Getting Started#

Requirements#

The requirements for Meet SDK for Android are:

  • Android Lollipop 5.0 (API Level 21) or above
  • Java 7 or higher
  • Gradle 4.1.0 or higher

Things To Be Noted Before You Get Started#

SDK License Key#

caution

Skip this step if you are already having your license key.

To integrate MirrorFly meet SDK into your app, you will need a SDK License Key. The MirrorFly server will use this license key to authenticate the SDK in your application.

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

license-key

Integrate the Meet SDK#

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

Step 2: 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 {
jcenter()
maven {
url "https://repo.mirrorfly.com/release"
}
}
}

Jcenter

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

dependencies {
implementation 'com.mirrorfly.sdk:mirrorflysdk:7.13.7'
}

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

android.enableJetifier=true

Step 5: Add required runtime permissions for calls click here

Initialize SDK For Meet#

To start using the sdk, there is a need for some basic requirements before proceeding with the initialization process. In your Application class, inside the onCreate() method use the below method from ChatManager to provide the necessary data.

configscyAar

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"));
}
});

ChatManager initializeSDK Function Description#

FunctionParameter TypeDescription
licenseKeyStringLicense key is required to proceed with registration
CALLBACKFlyCallbackFlyCallback is implemented and expressed as lambda expression

Add MyApplication#

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>

Registration#

caution

Skip this step if you are already completed the Registration in your application.

The below method to register a user in sandbox Live mode based on setIsTrialLicenceKey provided.

info

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 registerUser method will accept the FCM_TOKEN, FORCE_REGISTER, USER_TYPE and LIST<METADATA> as an optional param and pass it across.

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. 12345678@xmpp-preprod-sandbox.mirrorfly.com (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.
}
});
ArgumentTypeDescription
USER_IDENTIFIERStringA unique Id to Register the User. We accept only the AlphaNumeric String
FCM_TOKENStringA registration token that is generated by FCM SDK for the user's app instance to send message for free
FORCE_REGISTERbooleandefault value true provide true to force the logout of the old session If the registered user has reached the maximum no of multi-sessions or provide false to allow registration till the maximum no of multi-sessions
USER_TYPEStringtype of the user
META_DATAList<MetaData>list of key - value pair of metadata object. Maximum size is 3
CALLBACKFlyCallbackFlyCallback is used as a callback, implemented and expressed as lambda expression for easy reading
caution

If FORCE_REGISTER is false and it reached the maximum no of multi-sessions then registration will not succeed it will throw a 405 exception, Either FORCE_REGISTER should be true or one of the existing session need to be logged out to continue registration.

Note: If you want to use your own Id, you can use the userJid in the Register response.

Connect to the Chat Server#

Once Registration was successful, ChatSDK automatically attempts to connect to the Chat Server and ChatSDK also observe the changes in application lifecycle, and accordingly it will try to connect and disconnect the Chat Server.

Observe Connection Events#

Once the ChatConnectionListener has been set, you will be able to 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
}
});
ArgumentTypeDescription
CALLBACKChatConnectionListenercallback listener for chat connection

Preparing user jid#

To generate a JID for any user, use the below method.

FlyUtils.getJid(USER_NAME)
ArgumentTypeDescription
USER_NAMEStringunique username which we get from Register response.

Initialize Meet SDK#

In your Application class, inside the onCreate() method add the below lines:

ArgumentTypeDescription
MEET_UI_ACTIVITYClassActivity which needs to be invoked during meet.Meet sdk will start this activity with the meet details
@Override
public void onCreate() {
super.onCreate();
//set your call activity
CallManager.setCallActivityClass(MEET_UI_ACTIVITY.class);
CallManager.setMissedCallListener((isOneToOneCall, userJid, groupId, callType, userList,CallMetaData[] callMetaDataArray) -> {
//show missed call notification
});
CallManager.setCallHelper(new CallHelper() {
@NonNull
@Override
public String getNotificationContent(@NonNull String callDirection,CallMetaData[] callMetaDataArray) {
return CallNotificationHelper.getNotificationMessage();
}
});
CallManager.setCallNameHelper(new CallNameHelper() {
@NonNull
@Override
public String getDisplayName(@NonNull String jid,CallMetaData[] callMetaDataArray) {
return ContactManager.getDisplayName(jid);
}
});
}

Note: setCallNameHelper is optional, if it is not configured then user name will be empty in the ongoing meet notification.

Setup your call activity#

Meet UI Activity should be defined like below in your manifest

<activity
android:name="YOUR_MEET_ACTIVITY"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
android:excludeFromRecents="true"
android:launchMode="singleTask"
android:resizeableActivity="false"
android:screenOrientation="portrait"
android:supportsPictureInPicture="true"
android:showOnLockScreen="true"
android:turnScreenOn="true"
android:taskAffinity="call.video"
tools:targetApi="o_mr1" />

You need to call the below method on your meet activityonCreate() to configure the meet activity.

CallManager.configureCallActivity(YOUR_MEET_ACTIVITY);
ArgumentTypeDescription
ACTIVITYActivityinstance of the meet activity

You need to call the below method on onStart() from your meet activity to notify the meet sdk to remove the ongoing meet notification.

CallManager.bindCallService();

You need to call the below method on onStop() from your meet activity to notify the meet sdk to show the ongoing meet notification.

CallManager.unbindCallService();

Create meet link#

Initiate a meet by creating the meet link using the createMeetLink method. Once the meet link has been created successfully, you can share it with the other users/groups.

caution

If Group call feature is unavailable for your plan, then it will throw 403 exception

CallManager.createMeetLink((isSuccess, throwable, createMeetLinkData) -> {
if(isSuccess){
String meetlink = (String) createMeetLinkData.get("data");
}
});