Let's integrate our SDK in few minutes
#
Quick Start#
Chat SDKs for iOSMake an easy and efficient way with CONTUS MirrorFly Chat SDK for iOS - simply integrate the real-time chat features and functionalities into a client's app.
With client-side implementation, our chat SDK lets you initialize and configure the chat easily. With the server-side, Our solution ensures the most reliable infra-management services for the chat within the app. Furthermore, we will let you know how to install the chat SDK in your app for a better in-app chat experience.
Note : To obtain a fastest way in action using CONTUS MirrorFly Chat SDKs, you must try our trial app to enhance your chat app. So, just download our sample app and start with your app development. Click here to download the sample app.
#
RequirementsThe below are the requirements for chat SDK for iOS,
- Xcode 13 or later
- iOS 12.1 or later
- Swift 5.0 or later
#
Points to be Noted Before Making a Move#
SDK License KeyBefore proceeding with CONTUS MirrorFly Chat SDK integration, there must be an SDK license key that needs to be obtained for your MirrorFly application.
This SDK must be authenticated by the MirrorFly server by making use of the license key for further processing.
#
To obtain your license key you need to follow the below steps:Step 1: Signup into MirrorFly Console page (https://console.mirrorfly.com/register) to create a free MirrorFly account.
Step 2: You can provide your basic details like your name, organization details, work email, and contact number while creating an account.
Step 3: Once you’re in! You get access to your MirrorFly account ‘Overview page’ where you can find the downloadable iOS SDK for further integration process.
Step 4: To download the frameworks, click on the ‘Download’ button, this will take you to the top of this guided documentation page. Here, click on the given ‘Download button’ and extract the frameworks from the ZIP folder.
Step 5: After downloading the files, You have to create a new project to start with integration process to build your chat app for iOS.
#
Integrate Chat SDKSince the SDKs were compiled into multiple XCFramework binary packages you need to start with SDK integration. Thus, you have to follow the below given steps,
Step 1: First extract the xcframework files from the downloaded zip file that is provided at the top of this guided documentation. Once extracted you get the following xcframeworks.
- FlyCore.xcframework
- FlyCommon.xcframework
- FlyNetwork.xcframework
- FlyDatabase.xcframework
- FlyXmpp.xcframework
- FlyTranslate.xcframework
- FlyCall.xcframework
Step 2: Add all the extracted xcframeworks to your project.
Step 3 : Now, disable the bitcodes for your project
Step 4: 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.
Step 5: Add the below given pod hook code block at the end of the pod file and thus, finally install the pods.
Step 6: Now, enable all the below mentioned capabilities into your project.
Capabilities |
---|
App Groups |
Background Modes |
Now, go to the background mode and enable the below given modes
Background Modes |
---|
Audio,Airplay, and Picture in Picture |
Background fetch |
Remote notifications |
#
Configure the SDK server & DataNow, configure the server details in SDK and access the data globally using the AppDelegate class.
You can copy the license key from the 'Overview’ section in the Console dashboard.
#
Parameter DescriptionFunction | Parameter Type | Description |
---|---|---|
CONTAINER_ID | String | Create App groups and assign the obtained group container id. SDK uses this string to create the path for the local storage. |
#
Initialize ChatSDKTo start using the sdk, there are a few basic pieces of data that must be made available for the SDKs to function perfectly.
Thus, we utilize the usage of the ChatSDK
builder class making the data available for SDKs. Furthermore, in your project you must use the AppDelegate
class within the didFinishLaunchingWithOptions
method and also provide required data to build the ChatSDK Builder. Let's have a look at the example given below.
- Swift
- Objective-C
#
Chat Builder Function DescriptionFunction | Parameter Type | Description |
---|---|---|
setAppGroupContainerID | String | Pass group container id of the project that stores UserDefaults and Database |
setLicenseKey | String | Used to proceed with Registration |
isTrialLicense | Bool | If the obtained license key is a trial license key - display the message as true else false |
setDomainBaseUrl | String | Url required to make API calls |
buildAndInitialize | n/a | Initialize the chat configuration |
caution
The base url must have Http/Https protocol which should be closed with a slash (/)
, or else will display an exception bug message
.
#
RegistrationThe below method should be called to register a new user. This method will take care of both Sandbox
mode registration as well as Live
mode registration based on isTrialLicense
provided in the ChatSDK.Builder
class.
info
Unless you logged out of a session, make sure that you have called the Registration
method only once in an application
Note: If the below
registerApiService
methods are available at the time of registration then can be passed across for further processing wherein, can be accepted as an optional param.
- APNS_DEVICE_TOKEN
- VOIP_TOKEN
- IS_EXPORT
- Swift
- Objective-C
Argument | Type | Description |
---|---|---|
USER_IDENTIFIER | String | Unique Id to Register the User |
APNS_DEVICE_TOKEN | String | Token to register APNS device (optional) |
VOIP_DEVICE_TOKEN | String | Token to register VoIP device (optional) |
IS_EXPORT | Bool | true for production(apns certificate) builds and false for sandbox(apns certificate)builds |
CALLBACK | FlyCompletionHandler | FlyCompletionHandler is implemented and expressed as lambda expression |
To know more about
FlyCompletionHandler
clickhere
info
Save your own contact details in DB after registration. Your contact detail will be used while sending group messages. Call below method to save your own contact details,
To generate a unique user id, you must pass the username
in the method String userJID = FlyUtils.getJid(USERNAME)
#
Connect to the Chat ServerWhenever you are planning to send a message using the Chat SDK, first you have to establish a connection to the chat server using the below given method.
- Swift
- Objective-C
#
Disconnect Chat ServerUse the below given method to disconnect from the chat server call.
- Swift
- Objective-C
#
Observe Connection EventsThe connection status can be observed and tracked by confirming the ConnectionEventDelegate
. To do that you need to set ‘delegate’ in your ViewController
's viewDidAppear
method like below.
- Swift
- Objective-C
Once the ConnectionEventDelegate
has been set, you will be able to receive the connection status in the delegate method as mentioned below. Learn more about this method @ ConnectionEventDelegate
.
- Swift
- Objective-C
#
TerminologyThe below given are some of the common keyword/terminologies used in the Chat SDK with description
Keyword | Description |
---|---|
userID/userBareID | Unique 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) JID | userID+@+domain of the chat server Ex. 12345678@xmpp.chatsystem.dev.contus.us |
groupID/groupBareID | Unique 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` |
info
SDK here provides the built-in functions to prepare the JID and Group JID.
#
Send a One-to-One MessageThe below method is used to send a text message from one user to another.
Note: To generate a unique user id, you must call the other user's
username
in the methodString userJID = FlyUtils.getJid(USERNAME)
- Swift
- Objective-C
Argument | Type | Description |
---|---|---|
TO_JID | String | jid of the end user |
TEXT | String | Specifies the text message that needs to be sent |
REPLY_MESSAGE_ID | String | Provides the Message ID of replied message or else generates an empty string (optional) |
CALLBACK | SendMessageListener | callback to observe the action status |
#
Receive a One-to-One MessageSet the delegate in your ViewController
's viewDidAppear
method using below syntax and confirm the MessageEventsDelegate
class, this will enable you to see other incoming messages and related events.
- Swift
- Objective-C
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
To know more about other methods visit MessageEvent Delegate class,
- Swift
- Objective-C