Lets integrate our SDK in few minutes

SDK UIKit for iOS#

With MirrorFly UIKit for iOS, you can easily build an in-app chat with all the essential messaging features.

The MirrorFly UIKit for iOS is now available for you to build and customize views at a component level through modularization.

UIKit allows you to execute key chat functions using a view controller, which is composed of a module and a view model. While the module creates and displays the UI, the view model processes and updates relevant data from Chat SDK in each view. The view controller acts as the fundamental starting point of UIKit by allowing you to create and manage your UI.

Requirements#

The minimum requirements for Chat SDK for iOS

  • Xcode 14.1 or later
  • iOS 12.1 or later
  • Swift 5.0 or later

Things to be Noted Before Making a Start#

SDK License Key#

Note : Before proceeding with CONTUS MirrorFly Chat SDK integration, there must be an SDK license key that needs to be obtained for your MirrorFly 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

Get Started#

You can start building a messaging experience in your app by installing MirrorFly UIKit.

Step 1: Create a Project

To get started, open Xcode, create a new Swift Project

CreateNewProject

Step 2: If you have not initiated any pods project before, then initiate the one. Now, add the required pods that are necessary for the SDK to execute the process perfectly.

pod 'MirrorflyUIKit', '3.2.0'

Add the below given pod hook code block at the end of the pod file and thus, finally install the pods.

post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.1'
config.build_settings['ENABLE_BITCODE'] = 'NO'
config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'No'
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
end
end
end

Step 3: Adding Photo library usage description to your info.plist

PhotoLibrary

Step 4: Initialize with License Key

You can copy the license key from the 'Overview’ section in the Console dashboard.

let LICENSE_KEY = "xxxxxxxxxxxxxxxxxxxxxx" //"YOUR_LICENSE_KEY"
let USER_ID = "xxxxxxxxxxxxxxxxxxxxxx"

To integrate and run Mirrorfly UIKit in your app, you need to initialize it first. Initialize the MirrorFlyUI instance through your view controller.

Note : Use below to configure SDK in AppDelegate.

Initialize ChatSDK#

Add the following import statement below before accessing SDK anywhere in your project.

import MirrorFlySDK

In appdelegate didFinishLaunchingWithOptions function add SDK initialize method with valid Licensekey

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
ChatManager.initializeSDK(licenseKey: licenseKey) { isSuccess, error, data in
}
}

ViewController

Note : Use below method to initialize in ViewController.

Initialize UIKitSDK#

Add the following import statement below before accessing UIKitSDK anywhere in your project.

import FlyUIKit
func initialize () {
FlyUIKitSDK.shared.initialization(userID: USER_ID, isExport: IS_EXPORT) { isSuccess, error in
if isSuccess{
self.getRecentChat()
} else {
print(error)
}
}
}

Note : FlyUIKitConstants.IS_CALL_ENABLED should be set to true if the user wants to avail the call feature along with the chat feature, else FlyUIKitConstants.IS_CALL_ENABLED should be set to false to avail the chat feature alone.

The initialisation should be done with the parameters as below

ArgumentTypeDescription
userIDStringUnique UserID of the User
isExportBooltrue for production(apns certificate) builds and false for sandbox(apns certificate)builds
isChatHistoryEnableBooltrue To enable chat history and false for normal chat
CALLBACKCompletion Handler used to observe the action status with arguments as result - String, error - String

Step 5: Displaying RecentChat List

MFUIRecentChatListViewController is the starting point for launching UIKit in your app. Using the below code, you can fetch the complete list of the Recent Chats.

func getRecentChat() {
let recentChatListViewController = MFUIRecentChatListViewController()
recentChatListViewController.isInitialLoading = true
self.navigationController?.pushViewController(recentChatListViewController, animated: true)
}

Note : If you need to navigate directly to Chatview, Use the below method navigateToChatView() instead of getRecentChat()

MFUIChatViewParentController is the starting point for launching UIKit in your app. Using the below code, you can fetch the particular Chat view details.

func navigateToChatView() {
let userJid = try? FlyUtils.getJid(from: "Other UserID")
let recentChatListViewController = MFUIChatViewParentController(chatJid: userJid)
self.navigationController?.pushViewController(recentChatListViewController, animated: true)
}

Note : UIViewcontroller must embedded with UINavigationController.

RecentChatLight

Step 6: Send Your First Message

You can now run the app on a simulator or a plugged-in device. To send a message, you must first create a chat either single or group chat by tapping the icon in the top-right corner.

After the slection of the chat type, the app lands into the Contacts page with the all the registered users using the same license key. Then, you can select users you wish to start your chat with. Once the chat room has been created, enter your first message and send.

ChatLight

You've successfully sent your first message with MirrorFly.

Note : Great!!! We are now end of the Quick Start section. For Basic with various module navigation.Click here