Call Initialization

For call UI you need to do following setup, so the call feature can work properly

Add Background Modes#

In your project target, select signing & capabilities and add Background capabilities.

Goto Project -> Target -> Signing & Capabilities -> Click + at the top left corner -> Search for the capabilities below and add it
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
Voice over IP
Background fetch
Remote notifications

Capabilities

Add Microphone Privacy#

Add Microphone privacy description in your project plist

microphone

Add Camera Privacy#

Add Camera privacy description in your project plist

cameraUsage

Add Caller ringtone & reconnecting tone#

Add Caller ringtone & reconnecting tone mp3 file in your project.

ringtoneFile

The file name must follow in the following manner

.mp3 fileFile Name
Caller ringtonefly_call_ringtone
reconnecting tonefly_reconnecting_tone

To add a scene delegate, first, create a new Swift file that you’ll call SceneDelegate containing a subclass of UIResponder, just like the AppDelegate, and that conforms to UIWindowSceneDelegate. As your app might supports other versions than iOS 13, make this class only available for iOS 13.

class SceneDelegate: UIResponder, UIWindowSceneDelegate {
func sceneDidBecomeActive(_ scene: UIScene) {
if (FlyDefaults.isLoggedIn) {
ChatManager.connect()
}
}
func sceneDidEnterBackground(_ scene: UIScene) {
if (FlyDefaults.isLoggedIn) {
ChatManager.disconnect()
}
}
}

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

CallInitialize

func initialize () {
FlyUIKitConstants.CONTAINER_ID = "group.contus.FlyUIKitIntegrationApp"
let groupConfig = try? GroupConfig.Builder.enableGroupCreation(groupCreation: true)
.onlyAdminCanAddOrRemoveMembers(adminOnly: true)
.setMaximumMembersInAGroup(membersCount: 200)
.build()
assert(groupConfig != nil)
try? ChatSDK.Builder.setAppGroupContainerID(containerID: FlyUIKitConstants.CONTAINER_ID)
.setLicenseKey(key: licenseKey)
.isTrialLicense(isTrial: true)
.setDomainBaseUrl(baseUrl: BASE_URL)
.setGroupConfiguration(groupConfig: groupConfig!)
.buildAndInitialize()
FlyUIKitConstants.IS_CALL_ENABLED = true
FlyUIKitSDK.shared.initialization(userID: userId, licenseKey: licenseKey, base_Url: BASE_URL, isTrialLicense: true) { isSuccess, error in
if isSuccess{
self.getRecentChat()
} else {
print(error)
}
}
}

CallNotificationDelegate#

Initialize CallNotificationDelegate while initializing FlyUIKitSDK

FlyUIKitSDK.shared.initialization(userID: userId, licenseKey: licenseKey, base_Url: BASE_URL, isTrialLicense: true, isExport: false, selfObj: AppDelegate().self) {(isSuccess, error) in
if isSuccess {
} else {
}
}

Implement CallNotificationDelegate in AppDelegate to get MFUICallScreenViewController while attend the call

@available(iOS 13.0, *)
extension AppDelegate: CallNotificationDelegate {
func onCallAttended(vc: FlyUIKit.MFUICallScreenViewController?) {
}
}