Let's integrate our SDK in few minutes

Download SDK Files

Chat SDKs for iOS#

Through our iOS Chat SDK, you can efficiently integrate real-time chat into your app. On the client-side implementation, you can initialize, configure and build the chat with minimal effort.

On the server-side, MirrorFly ensures reliable infra-management services for your chat within the app. All server setup related documents can be downloaded from control panel's download section.

Note : The fastest way to see our Chat SDK in action is to build your chat app on top of our sample app. To download the sample app click here


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

SDK License Key#

Your SDK must be authenticated by MirrorFly server using License Key.

Please follow below step to get your license key:

1: Signup to create an account in MirrorFly Console, if you already have an account please Sign In.

2: Copy license key under "Application info" in "Overview" page


Integrate Chat SDK#

The SDK's were compiled into multiple XCFramework binary packages. To start integrating the SDK's, follow the below steps,

Step 1: Extract the xcframework files from the downloaded zip file. After extraction you will have the following xcframeworks.

  • FlyCore.xcframework
  • FlyCommon.xcframework
  • FlyNetwork.xcframework
  • FlyDatabase.xcframework
  • FlyXmpp.xcframework
  • FlyTranslate.xcframework


Step 2: Add all the extracted xcframeworks to your project.

Goto Project -> Target -> General -> Frameworks,libraries and Embedded Content -> Select Embed & Sign for all the Chat SDK's xcframeworks


Step 3 : Disable Bitcode for your project

Goto Project -> Build Settings -> Filter the term `Bitcode` -> and select No from the dropdown


Step 4: Init a pods project if not before, and add the pods necessary for the SDK to function properly.

pod 'libPhoneNumber-iOS'
pod 'Alamofire'
pod 'RealmSwift', '10.20.1'
pod 'XMPPFramework/Swift'
pod 'SocketRocket'
pod 'Socket.IO-Client-Swift'

Step 5: Add the following pod hook code block at the end of the pod file and 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'


Step 6: Enable the capabilities mentioned below in your project.

Goto Project -> Target -> Signing & Capabilities -> Click + at the top left corner -> Search for the capabilities below
App Groups
Background Modes

In background modes enable the following modes

Background Modes
Audio,Airplay, and Picture in Picture
Background fetch
Remote notifications



Configure the SDK server and configuration data globally. Preferably in AppDeleagte.

let BASE_URL = "https://api-preprod-sandbox.mirrorfly.com/api/v1/"
let LICENSE_KEY = "xxxxxxxxxxxxxxxxxxxxxx"
let CONTAINER_ID = "group.com.mirrorfly.qa"

Initialize ChatSDK#

To start using the sdk, there are few data that were critical for the SDK to function properly. For which we make use of the ChatSDK builder class to provide data to SDK. In your project AppDelegate class inside the didFinishLaunchingWithOptions method build the ChatSDK Builder and provide the necessary data. An example can be found below.

try? ChatSDK.Builder.setAppGroupContainerID(containerID: CONTAINER_ID)
.setLicenseKey(key: LICENSE_KEY)
.isTrialLicense(isTrial: true)
.setDomainBaseUrl(baseUrl: BASE_URL)


Chat Builder Function Description#

FunctionParameter TypeDescription
setAppGroupContainerIDStringPass group container id of the project to store UserDefaults and Database
setLicenseKeyStringlicense key needed for registration api provided by Chat team
isTrialLicenseBooltrue if provided licence key is trial licence key else false
setDomainBaseUrlStringUrl needed for api calls provided by Chat team

|buildAndInitialize | n/a | Initialize the chat configuration|


Base url must have http/https protocol and should end with / else an exception will be thrown.


To register a new user call the below method. This method will take care of Sandbox mode registration as well as Live mode registration based on isTrialLicense provided in the ChatSDK.Builder class.


The Registration method should be called only once until the user Logs out.

Note: The below registerApiService method also accepts APNS_DEVICE_TOKEN, VOIP_TOKEN and IS_EXPORT as an optional param. If those data were available at the time of registration, we can pass them too

try! ChatManager.registerApiService(for: USER_IDENTIFIER ) { isSuccess, flyError, flyData in
var data = flyData
if isSuccess {
// This is your Password
guard let password = data["password"] as? String else{
// This is your Username
guard let username = data["username"] as? String else{
let error = data.getMessage()
print("#chatSDK \(error)")
USER_IDENTIFIERStringUnique Id to Register the User
APNS_DEVICE_TOKENStringAPNS device token (optional)
VOIP_DEVICE_TOKENStringVOIP device token (optional)
IS_EXPORTBoolwhile exporting ipa set it to true else false.
CALLBACKFlyCompletionHanlderFlyCompletionHanlder implemented as lambda expression

To know more about FlyCompletionHanlder click here

Connect to the Chat Server#

In order to send messages using the Chat SDK, we first needed to establish a connection to the chat server. Call the below method to connect to the Chat Server.


Disconnect Chat Server#

To disconnect from the chat server call the below method.


Observe Connection Events#

You can observe the connection status by conforming to the ConnectionEventDelegate. Set the delegate in your ViewController's viewDidAppear method like below.

ChatManager.shared.connectionDelegate = self

Once the ConnectionEventDelegate delegate has been set, we will be able to receive the connection status in the delegate method mentioned below.To know more about the methods in ConnectionEventDelegate kindly visit ConnectionEvent Delegate

func onConnected() {
// Navigate to Conversation screen


The below table contains some of the mostly used keywords in sdk and in the documentation with their explanation

userID/userBareIDUnique 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
userJid (or) JIDuserID+@+domain of the chat server Ex. 12345678@xmpp.chatsystem.dev.contus.us
groupID/groupBareIDUnique ID assigned for each group Ex: group123456 (any alphanumeric). GroupJID = groupID +@mix.+domain of the chat server Ex: group123456@mix.xmpp.mirrorfly.dev.contus.us`

SDK provides the built-in functions to prepare the JID, Group JID.

Send a message#

Use the below method to send a text message to other user,

Note:To generate a unique user id, pass other user's username to this method let userJID = FlyUtils.getJid(USERNAME)

FlyMessenger.sendTextMessage(TO_JID, TEXT) { isSuccess,error,chatMessage in
if isSuccess {
// Update the UI
// Handle the error
TO_JIDStringjid of the end user
TEXTStringtext message to be sent
REPLY_MESSAGE_IDStringif it is a reply message for message A, then message A's messageId otherwise empty string (optional)
CALLBACKSendMessageListenercallback to observe the action status

Receive a message#

By Conforming to the MessageEventsDelegate we can observe the incoming messages and other message related events. Set the delegate in your ViewController's viewDidAppear method like below.

ChatManager.shared.messageEventsDelegate = self

Once the delegate has been set, we will be able to receive the incoming message in the method mentioned below.To know more about other methods in MessageEventsDelegate kindly visit MessageEvent Delegate

func onMessageReceived(message: ChatMessage, chatJid: String) {
// Message received from chatJid, content is message.messageTextContent