Let's integrate our SDK in few minutes

Quick Start#

Meet SDK for iOS#

With CONTUS MirrorFly Meet SDK for iOS, 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

Integrate Meet SDK#

Requirements#

The below are the requirements for meet SDK for iOS,

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

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

Step 4: Download the iOS SDK

license-key

Getting Started#

Step 1: Add the following ChatSDK pod to your Podfile. If pod hasn't been initialised yet means, create a Podfile by executing pod init command.

pod 'MirrorFlySDK', '5.17.5'

Step 2: Add the below given pod hook code block at the end of the pod file and thus, finally install the pods by executing pod install command.

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['EXCLUDED_ARCHS[sdk=iphonesimulators*]'] = 'arm64'
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
end
end
end

Step 3 : Now, disable the bitcode for your project

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

Bitcode

Step 4: Now, enable all the below mentioned capabilities into your project.

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

Step 5: Enable Audio and Video record permisions.

Provide Microphone and Camera usage description in the plist file of your project.

Configure the SDK server & Data#

Now, configure the server details in SDK and access the data globally using the AppDelegate class.

let LICENSE_KEY = "xxxxxxxxxxxxxxxxxxxxxx"
let CONTAINER_ID = "xxxxxxxxxxxxxxxxxxxxxx"

Initialize Data for Meet#

To 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 initializeSDK function to validate the license key and to fetch critical data from server for SDK initialization. Furthermore, in your project you must use the AppDelegate class within the didFinishLaunchingWithOptions method call the initialization method by passing the license key. Let's have a look at the example given below.

    ChatManager.initializeSDK(licenseKey: LICENSE_KEY) { isSuccess, flyError, flyData in }

    AppDelegate

    ArgumentTypeDescription
    LICENSE_KEYStringUsed to proceed with Registration
    CALLBACKFlyCompletionHandlerFlyCompletionHandler is implemented and expressed as lambda expression

    Registration#

    You can use the below given method to register a new user.

    info

    Unless you logged out of a session, make sure that you have called the Registration method only once in an application

    Note: While registration, the below registerApiService method will accept the additional params required for notification processing on server and IS_FORCE_REGISTER as an optional param for maintaining sessions, USER_TYPE as an optional param to provide type of user and META_DATA as an optional param to provide MetaData of user.

      try! ChatManager.registerApiService(for: USER_IDENTIFIER ) { isSuccess, flyError, flyData in
      var data = flyData
      if isSuccess {
      // This is your Username
      guard let username = data["username"] as? String else{
      return
      }
      // This is your JID
      // Ex. 12345678@xmpp-preprod-sandbox.mirrorfly.com (USER_IDENTIFIER+@+domain of the chat server)
      guard let userJid = data["userJid"] as? String else{
      return
      }
      }else{
      let error = data.getMessage()
      print("#chatSDK \(error)")
      }
      }
      ArgumentTypeDescription
      USER_IDENTIFIERStringUnique Id to Register the User. User identifiers can only contain lowercase alphanumeric characters, hyphens (-), and underscores (_).
      APNS_DEVICE_TOKENStringToken to register APNS device (optional)
      VOIP_DEVICE_TOKENStringToken to register VoIP device (optional)
      IS_EXPORTBooltrue for production(apns certificate) builds and false for sandbox(apns certificate)builds
      IS_FORCE_REGISTERBooldefault 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 (optional)
      META_DATA[MetaData]list of key - value pair of metadata object. Maximum size is 3 (optional)
      CALLBACKFlyCompletionHanlderFlyCompletionHanlder is implemented and expressed as lambda expression for easy reading

      To know more about FlyCompletionHanlder click here

      caution

      If IS_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 IS_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#

      In order to send the meet link as a message to other user/group, we can make use of Chat server.Once Registration was successful, ChatSDK automatically attempts to connect to the Chat Server and ChatSDK also observe the changes in application state, and accordingly it will try to connect and disconnect the Chat Server.

      Observe Connection Events#

      The 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.

        ChatManager.shared.connectionDelegate = self

        Once the ConnectionEventDelegate has been set, you will be able to receive the connection status in the delegate method as mentioned below.

          func onConnected() {
          // Navigate to Conversation screen
          }

          To know more about ConnectionEventDelegate visit ConnectionEvent Delegate

          Observe Meet Events#

          To observe Meet events create and set a Singleton Class that conforms to the CallManagerDelegate and pass that object to the below method.

            CallManager.setCallEventsDelegate(delegate: CALLMANAGER_DELEGATE)
            ArgumentType
            CALLMANAGER_DELEGATECallManagerDelegate

            Preparing user jid#

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

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

              Setup Meet UI#

              To set the Meet UI that has to be presented during a meet, call the below method. An instantiated view controller object has to be passed in the method.

                CallManager.setCallViewController(CALL_VIEW_CONTROLLER)
                ArgumentTypeDescription
                CALL_VIEW_CONTROLLERUIViewControllerA class that conforms to UIViewController

                Presenting meet UI#

                Meet SDK handles the UI presentation for the meet. Call the below method after declaring the Meet SDK and or before joining a meeting.The below method sets the view on top of which the meet ui will be presented.

                  CallManager.setViewToPresentController("VIEW_TO_PRESENT")
                  ArgumentDescription
                  VIEW_TO_PRESENTViewController in which Meet UI has to be presented.
                  info

                  Setting the CallManager.setViewToPresentController is optional else the Meet SDK will present the UI on top of the project's root viewcontroller.

                  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 { [weak self] (isSuccess , error, data) in
                    if isSuccess {
                    // The data dictionary will contain the nelwy generated unique meet id
                    // let meetId = data['data'] as! String
                    }
                    }
                    caution

                    To join a meet, Microphone and Camera usage permissions were required. Meet SDK also provides method to check those permissions like CallManager.isAudioCallPermissionsGranted() and CallManager.isVideoCallPermissionsGranted(). We can also make use of these methods too.