Contacts List

Initialize#

You start building the contact sync by calling the MFUICreateChatViewController class. It uses MFUIContactCell class to display the contacts list in the controller.

The MFUICreateChatViewController should get initialised with the chat type (single or group chat) obtained from the previous screen.

open func showCreateSingleChat(type: ChatCreationType = .newSinglehChat) {
let createChatVC = MFUIViewControllerSet.CreateChatViewController.init(type: type)
self.navigationController?.pushViewController(createChatVC, animated: true)
}

Usage#

The following items are key elements of MFUICreateChatViewController that are used to create a functional chat.

Module components#

In the MFUICreateChatViewController class, MFUICreateChatModule and its components are used to create and display the chat view. The module is composed of three components: headerComponent and listComponent.

Property nameType
headerComponentMFUICreateChatModule.Header
listComponentMFUICreateChatModule.List

Header Component#

The headerComponent includes a default title as Contacts, a back button that takes the user to the previous view. Each property corresponds to the elements in the navigation bar of the view controller.

The following table shows the parameters of the configure method of the headerComponent.

Parameter nameType
delegateMFUICreateChatModuleHeaderDelegate
themeMFContactListTheme

List Component#

The listComponent shows a list of all contacts after the contacts being synced. The following table shows the parameters of the configure method of the listComponent.

Parameter nameType
delegateMFUICreateChatModuleListDelegate
dataSourceMFUICreateChatModuleListDataSource
themeMFContactListTheme

View Model#

The MFUICreateChatViewController class uses a view model that is a type of the MFUICreateChatViewModel class. The view model is created in the initializer of the view controller through the createViewModel(contacts: type:) method. When the view model object is created, it retrieves contacts list data from Chat SDK to the view controller and updates the view through the createChatViewModel(_:didChangeUsers:needsToReload:) event.

The following table shows the parameters list of the createViewModel method

Parameter nameType
contactsProfileDetails
typeChatCreationType = .newSinglehChat

Used the following function to get the Users list from the SDK who are all using the same license key.

ContactManager.shared.getUsersList(pageNo, pageSize, search){ isSuccess,flyError,flyData in
if isSuccess{
var data = flyData
if let profileArray = data.getData() as? [ProfileDetails]{}
let totalPages = data["totalPages"] as? Int
let totalUsers = data["totalRecords"] as? Int
} else {
//print error
}
});
ArgumentTypeDescription
pageNointPage number of user list default value 1
pageSizeintNumber of users per page default value 50
searchStringtext characters for which search has to happen default value empty
CALLBACKFlyCompletionHandlerFlyCompletionHandler used as completion Handler