Integrate the Chat SDK

Step 1: Add the following to your POD file.

target 'Runner' do
use_modular_headers!
pod 'Mirrorfly-ios-framework', :git => 'https://github.com/MirrorFly/Mirrorfly-ios-framework.git', :branch => 'pod_qa'
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(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'
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
end
end
end

Step 2: 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
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

Capabilities

Configure the SDK server & Data#

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

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

Step 7:Download and extract the iOS supporing files and move into iOS project under Runner directory.

  • Commons
  • FlyEvents
  • FlySdkMethodCalls
  • JsonSerializer
  • FlyBaseController

Initialize ChatSDK#

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

override func application(_ application: UIApplication,didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let controller : FlutterViewController = window?.rootViewController as! FlutterViewController
...
FlyBaseController().initSDK(controller: controller, licenseKey: LICENSE_KEY, isTrial: !IS_LIVE, baseUrl: BASE_URL, containerID: CONTAINER_ID)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
override func applicationDidBecomeActive(_ application: UIApplication) {
FlyBaseController().applicationDidBecomeActive()
}
override func applicationDidEnterBackground(_ application: UIApplication) {
FlyBaseController().applicationDidEnterBackground()
}

Chat Builder Function Description#

FunctionParameter TypeDescription
setAppGroupContainerIDStringPass group container id of the project that stores UserDefaults and Database
setLicenseKeyStringUsed to proceed with Registration
isTrialLicenseBoolIf the obtained license key is a trial license key - display the message as true else false
setDomainBaseUrlStringUrl required to make API calls
buildAndInitializen/aInitialize 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.