Skip to main content
Version: v5

Call Logs

Overview

CometChatCallLogs is a Component that shows the list of Call Log available . By default, names are shown for all listed users, along with their avatar if available.

Image

The Call Logs component is composed of the following BaseComponents:

ComponentsDescription
CometChatListBaseCometChatListBase is a container component featuring a title, customizable background options, and a dedicated list view for seamless integration within your application's interface.
CometChatListItemThis component displays data retrieved from a CallLog object on a card, presenting a title and subtitle.

Usage

Integration

CometChatCallLogs being a custom view controller, offers versatility in its integration. It can be seamlessly launched via button clicks or any user-triggered action, enhancing the overall user experience and facilitating smoother interactions within the application.

// To navigate to the CometChatCallLogs
let callLogs = CometChatCallLogs()
self.navigationController?.pushViewController(callLogs, animated: true)

Actions

Actions dictate how a component functions. They are divided into two types: Predefined and User-defined. You can override either type, allowing you to tailor the behavior of the component to fit your specific needs.

  1. set(onItemClick:)

set(OnItemClick:) is triggered when you click on a ListItem of the Conversations component. This set(OnItemClick:) method proves beneficial when a user intends to customize the on-click behavior in CometChatCallLogs.

// syntax for set(onItemClick: @escaping ((_ callLog: CometChatCallsSDK.CallLog, _ indexPath: IndexPath) -> Void))
cometChatCallLogs.set(onItemClick: { callLogs, indexPath in
// Override on item click
})


  1. set(OnItemLongClick:)

set(OnItemLongClick:) is triggered when you long press on a ListItem of the Call logs component. This set(OnItemLongClick:) method proves beneficial when a user intends to additional functionality on long press on list item in CometChatCallLogs.

// syntax for set(onItemLongClick: @escaping ((_ callLog: CometChatCallsSDK.CallLog, _ indexPath: IndexPath) -> Void))
cometChatCallLogs.set(onItemLongClick: { callLog, indexPath in
// Override on item click
})


3. set(onBack:)

This set(onBack:) method becomes valuable when a user needs to override the action triggered upon pressing the back button in CometChatCallLogs.

cometChatCallLogs.set(onBack: {
// Override on back
})

4. set(onError:)

This method proves helpful when a user needs to customize the action taken upon encountering an error in CometChatCallLogs.

cometChatCallLogs.set(onError: { error in
// Override on error
})


5. set(onEmpty:)

This set(onEmpty:) method is triggered when the call logs list is empty in CometChatCallLogs.

cometChatCallLogs.set(onEmpty: {

})


6. setOnLoad

This set(onLoad:) method is triggered when call logs are successfully loaded in CometChatCallLogs.

cometChatCallLogs.set(onLoad: { callLogs in
})


Filters

Filters allow you to customize the data displayed in a list within a Component. You can filter the list based on your specific criteria, allowing for a more customized. Filters can be applied using RequestBuilders of Chat SDK.

1. CallRequestBuilder

The callRequestBuilder enables you to filter and customize the call list based on available parameters in callRequestBuilder. This feature allows you to create more specific and targeted queries during the call. The following are the parameters available in callRequestBuilder

MethodDescriptionCode
fetchPreviousFetches previous call logsfetchPrevious(authToken: String, onSuccess: (([CallLog]) -> Void), onError: (_ error: CometChatCallException?) -> Void)
fetchNextFetches next call logsfetchNext(onSuccess: (([CallLog]) -> Void), onError: (_ error: CometChatCallException?) -> Void)
limitSets the limit for the call logs request.set(limit: Int)
callTypeSets the call type for the call logs request.set(callType: CallType)
callStatusSets the call status for the call logs request.set(callStatus: CallStatus)
hasRecordingSets the recording status for the call logs request.set(hasRecording: Bool)
callDirectionSets the call direction for the call logs request.set(callDirection: CallDirection)
uidSets the user ID for the call logs request.set(uid: String)
guidSets the group ID for the call logs request.set(guid: String)
authTokenSets the auth token for the call logs request.set(authToken: String?)
buildBuilds the call logs request.build()

Example

In the example below, we are applying a filter based on limit , calltype and call status.


let callRequestBuilder = CallLogsRequest.CallLogsBuilder()
.set(limit: 2)
.set(callType: .audio)
.set(callStatus: .initiated)

// To navigate to the CometChatCallLogs
let callLogs = CometChatCallLogs()
.set(callRequestBuilder: callRequestBuilder)

self.navigationController?.pushViewController(callLogs, animated: true)

Events

Events are emitted by a Component. By using event you can extend existing functionality. Being global events, they can be applied in Multiple Locations and are capable of being Added or Removed.

The Call Logs component does not have any exposed events.


Customization

To fit your app's design requirements, you can customize the appearance of the conversation component. We provide exposed methods that allow you to modify the experience and behavior according to your specific needs.

Style

Using Style you can customize the look and feel of the component in your app, These parameters typically control elements such as the color, size, shape, and fonts used within the component.

1. CallLog Style

You can customize the appearance of the CallLog Component by applying the CallLogStyle to it using the following code snippet.

Global level styling

let customAvatarStyle = AvatarStyle()
customAvatarStyle.backgroundColor = UIColor(hex: "#FBAA75")
customAvatarStyle.cornerRadius = CometChatCornerStyle(cornerRadius: 8)

CometChatCallLogs.style.titleColor = UIColor(hex: "#F76808")
CometChatCallLogs.style.titleFont = UIFont(name: "Times-New-Roman", size: 34)
CometChatCallLogs.avatarStyle = customAvatarStyle

Instance level styling

let customAvatarStyle = AvatarStyle()
customAvatarStyle.backgroundColor = UIColor(hex: "#FBAA75")
customAvatarStyle.cornerRadius = CometChatCornerStyle(cornerRadius: 20)

let callLogStyle = CallLogStyle()
callLogStyle.titleColor = UIColor(hex: "#F76808")
callLogStyle.titleFont = UIFont(name: "Times-New-Roman", size: 34)

let callLog = CometChatCallLogs()
callLog.style = callLogStyle
callLog.avatarStyle = customAvatarStyle
Image

List of properties exposed by CallLogStyle

PropertyDefault ValueDescription
List Item Styles
listItemTitleTextColorCometChatTheme.textColorPrimaryText color for the list item title.
listItemTitleFontCometChatTypography.Heading4.mediumFont for the list item title.
listItemSubTitleTextColorCometChatTheme.textColorSecondaryText color for the list item subtitle.
listItemSubTitleFontCometChatTypography.Body.regularFont for the list item subtitle.
listItemBackgroundCometChatTheme.backgroundColor01Background color for the list item.
listItemSelectedBackgroundCometChatTheme.backgroundColor01Background color for the selected list item.
listItemBorderWidth0Border width for the list item.
listItemBorderColorCometChatTheme.borderColorLightBorder color for the list item.
listItemCornerRadius.init(cornerRadius: 0)Corner radius for the list item.
listItemSelectionImageTint.clearTint color for the selection image.
listItemDeSelectedImageTint.clearTint color for the deselected image.
listItemSelectedImageUIImage()Image for the selected list item.
listItemDeSelectedImageUIImage()Image for the deselected list item.
Background Styles
backgroundColorCometChatTheme.backgroundColor01Background color.
borderWidth0Border width.
borderColorCometChatTheme.borderColorLightBorder color.
cornerRadius.init(cornerRadius: 0)Corner radius.
Title Styles
titleColorCometChatTheme.textColorPrimaryText color for the title.
titleFontCometChatTypography.Heading4.boldFont for the title.
largeTitleColorCometChatTheme.textColorPrimaryText color for large titles.
largeTitleFontnilFont for large titles.
Navigation Bar Styles
navigationBarTintColorCometChatTheme.backgroundColor01Background color for the navigation bar.
navigationBarItemsTintColorCometChatTheme.iconColorPrimaryTint color for navigation bar items.
Error Message Styles
errorTitleTextFontCometChatTypography.Heading4.boldFont for the error title.
errorTitleTextColorCometChatTheme.textColorPrimaryText color for the error title.
errorSubTitleFontCometChatTypography.Body.regularFont for the error subtitle.
errorSubTitleTextColorCometChatTheme.textColorSecondaryText color for the error subtitle.
Retry Button Styles
retryButtonTextColorCometChatTheme.whiteText color for the retry button.
retryButtonTextFontCometChatTypography.Button.mediumFont for the retry button text.
retryButtonBackgroundColorCometChatTheme.primaryColorBackground color for the retry button.
retryButtonBorderColor.clearBorder color for the retry button.
retryButtonBorderWidth0Border width for the retry button.
retryButtonCornerRadius.init(cornerRadius: 0)Corner radius for the retry button.
Empty State Styles
emptyTitleTextFontCometChatTypography.Heading4.boldFont for the empty state title.
emptyTitleTextColorCometChatTheme.textColorPrimaryText color for the empty state title.
emptySubTitleFontCometChatTypography.Body.regularFont for the empty state subtitle.
emptySubTitleTextColorCometChatTheme.textColorSecondaryText color for the empty state subtitle.
TableView Styles
tableViewSeparator.clearColor for the table view separator.
Icon Styles
backIconnilIcon for the back button.
backIconTintCometChatTheme.iconColorPrimaryTint color for the back icon.
incomingCallIconSystem icon for "arrow.down.left"Icon for incoming calls.
incomingCallIconTintCometChatTheme.errorColorTint color for the incoming call icon.
outgoingCallIconSystem icon for "arrow.up.right"Icon for outgoing calls.
outgoingCallIconTintCometChatTheme.successColorTint color for the outgoing call icon.
missedCallTitleColorCometChatTheme.errorColorText color for missed call titles.
missedCallIconnilIcon for missed calls.
missedCallIconTintCometChatTheme.errorColorTint color for the missed call icon.
audioCallIconSystem icon for "phone"Icon for audio calls.
audioCallIconTintCometChatTheme.iconColorPrimaryTint color for the audio call icon.
videoCallIconSystem icon for "video"Icon for video calls.
videoCallIconTintCometChatTheme.iconColorPrimaryTint color for the video call icon.
separatorColor.clearColor for separators.

Functionality

These are a set of small functional customizations that allow you to fine-tune the overall experience of the component. With these, you can change text, set custom icons, and toggle the visibility of UI elements.

Below is a list of customizations along with corresponding code snippets

PropertyDescriptionCode
callRequestBuilderSets the CallLogsBuilder instance for call logs..set(callRequestBuilder: Any)
hideErrorHides the error state view.hideError = true
hideNavigationBarHides the navigation bar.hideNavigationBar = true
hideLoadingStateHides the loading state view.hideLoadingState = true
hideBackIconHides the back icon in the navigation bar.hideBackIcon = true

Advance

For advanced-level customization, you can set custom views to the component. This lets you tailor each aspect of the component to fit your exact needs and application aesthetics. You can create and define your views, layouts, and UI elements and then incorporate those into the component.

SetListItemView

With this function, you can assign a custom ListItem to the CallLogs Component.

let callLogs = CometChatCallLogs()
callLogs.set(listItemView: { callLog in
let view = CustomListItem()
return view
})
Image
import UIKit
import CometChatUIKitSwift
import CometChatCallsSDK

class CustomListItem: UIView {
// Initialize UI components
public var callImage: UIImageView = {
let imageView = UIImageView()
imageView.translatesAutoresizingMaskIntoConstraints = false
return imageView
}()

public var nameLabel: UILabel = {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
return label
}()

public var subTitleLabel: UILabel = {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.textAlignment = .center
label.textColor = .lightGray
return label
}()

public var dateLabel: UILabel = {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.textAlignment = .center
label.textColor = .systemGray3
return label
}()

public var detailStackView: UIStackView = {
let stack = UIStackView()
stack.translatesAutoresizingMaskIntoConstraints = false
stack.alignment = .leading
stack.distribution = .fill
stack.spacing = 4
return stack
}()

override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}

required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

private func setupUI() {
addSubview(callImage)
addSubview(detailStackView)
detailStackView.addArrangedSubview(nameLabel)
detailStackView.addArrangedSubview(subTitleLabel)
addSubview(dateLabel)

NSLayoutConstraint.activate([
callImage.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 8),
callImage.centerYAnchor.constraint(equalTo: centerYAnchor),
callImage.widthAnchor.constraint(equalToConstant: 40),
callImage.heightAnchor.constraint(equalToConstant: 40),

detailStackView.leadingAnchor.constraint(equalTo: callImage.trailingAnchor, constant: 8),
detailStackView.trailingAnchor.constraint(equalTo: dateLabel.trailingAnchor, constant: -8),
detailStackView.centerYAnchor.constraint(equalTo: callImage.centerYAnchor),

dateLabel.centerYAnchor.constraint(equalTo: callImage.centerYAnchor),
dateLabel.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -12)
])
}
}

You can indeed create a custom listitem UIView file named CustomListItem for more complex or unique list items.

Afterwards, seamlessly integrate this CustomListItem UIView file into the .setListItemView method within CometChatCallLogs().


SetTitleView

You can create a custom Title view for more complex or unique list items and integrate this CustomTitleView UIView file into the .set(titleView:) method within CometChatCallLogs().

let callLogs = CometChatCallLogs()
callLogs.set(titleView: { callLog in
let view = CustomTitleView()
view.configure(callLog: callLog)
return view
})

Example

Image
import UIKit
import CometChatUIKitSwift
import CometChatSDK
import CometChatCallsSDK

import UIKit

class CustomTitleView: UIView {

private let nameLabel: UILabel = {
let label = UILabel()
label.font = UIFont.systemFont(ofSize: 16, weight: .semibold)
label.textColor = .black
return label
}()

private let separatorLabel: UILabel = {
let label = UILabel()
label.text = "•"
label.font = UIFont.systemFont(ofSize: 16, weight: .regular)
label.textColor = .gray
return label
}()

private let clockIcon: UIImageView = {
let imageView = UIImageView(image: UIImage(systemName: "clock.fill"))
imageView.tintColor = .gray
imageView.contentMode = .scaleAspectFit
return imageView
}()

private let timeLabel: UILabel = {
let label = UILabel()
label.font = UIFont.systemFont(ofSize: 16, weight: .regular)
label.textColor = .gray
return label
}()

private let stackView: UIStackView = {
let stackView = UIStackView()
stackView.axis = .horizontal
stackView.alignment = .center
stackView.spacing = 4
return stackView
}()

override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

private func setupUI() {
stackView.addArrangedSubview(nameLabel)
stackView.addArrangedSubview(separatorLabel)
stackView.addArrangedSubview(clockIcon)
stackView.addArrangedSubview(timeLabel)

addSubview(stackView)
stackView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
stackView.leadingAnchor.constraint(equalTo: leadingAnchor),
stackView.topAnchor.constraint(equalTo: topAnchor),
stackView.bottomAnchor.constraint(equalTo: bottomAnchor),
stackView.trailingAnchor.constraint(equalTo: trailingAnchor)
])
}

func configure(callLog: CometChatCallsSDK.CallLog){

if let group = (callLog.receiver as? CallGroup) {
callGroup = group
} else if let initiator = (callLog.initiator as? CallUser), initiator.uid != CometChatUIKit.getLoggedInUser()?.uid {
callUser = initiator
} else if let receiver = (callLog.receiver as? CallUser) {
callUser = receiver
}

nameLabel.text = callUser?.name ?? callGroup?.name ?? ""
timeLabel.text = formatTime(seconds: (participant?.totalDurationInMinutes ?? 0.0)*60)
}
}


SetLeadingView

You can create a custom Title view for more complex or unique list items and integrate this CustomLeadingView UIView file into the .set(leadingView:) method within CometChatCallLogs().

let callLogs = CometChatCallLogs()
callLogs.set(leadingView: { callLog in
let view = CustomLeadingView()
view.configure(callLog: callLog)
return view
})

Example

Image
import UIKit
import CometChatUIKitSwift
import CometChatSDK
import CometChatCallsSDK

import UIKit

class CustomLeadingView: UIButton {

override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

private func setupUI() {
let callIcon = UIImage(systemName: "phone.arrow.up.right")?.withRenderingMode(.alwaysTemplate)
setImage(callIcon, for: .normal)
tintColor = UIColor.purple
backgroundColor = UIColor.purple.withAlphaComponent(0.1)
layer.cornerRadius = 24 // Make it circular
clipsToBounds = true

NSLayoutConstraint.activate([
widthAnchor.constraint(equalToConstant: 48),
heightAnchor.constraint(equalToConstant: 48)
])
}

func configure(callLog: CometChatCallsSDK.CallLog){
var image = UIImage()
switch callLog?.status {
case .busy, .unanswered, .rejected, .cancelled:
image = UIImage(named: "missed_call_image")
case .initiated, .ongoing, .ended:
if isInitiator{
image = UIImage(systemName: "arrow.up.right")
}else{
image = UIImage(systemName: "arrow.down.left")
}
case .none:
break
@unknown default:
break
}
self.setImage(image, for: .normal)
}
}

SetSubTitleView

You can customize the subtitle view for each callLog item to meet your requirements.

You can indeed create a custom Subtitleview UIView file named SubtitleView for more complex or unique list items.

Afterwards, seamlessly integrate this SubtitleView UIView file into the .setSubtitle method within CometChatCallLogs().

let callLogs = CometChatCallLogs()
callLogs.set(subtitleView: { callLog in
let view = CustomSubtitleView()
return view
})

Example

Image
import UIKit
import CometChatUIKitSwift
import CometChatSDK
import CometChatCallsSDK

class CustomSubtitleView: UIView {

// MARK: - Properties
private let subtitleLabel: UILabel = {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.font = UIFont.systemFont(ofSize: 14, weight: .regular) // Customize font
label.textColor = .darkGray // Customize text color
label.numberOfLines = 1 // Single line
label.textAlignment = .left // Align to the left
return label
}()

// MARK: - Initializers
override init(frame: CGRect) {
super.init(frame: frame)
setupView()
}

required init?(coder: NSCoder) {
super.init(coder: coder)
setupView()
}

// MARK: - Setup
private func setupView() {
addSubview(subtitleLabel)

// Constraints
NSLayoutConstraint.activate([
subtitleLabel.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 8),
subtitleLabel.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -8),
subtitleLabel.topAnchor.constraint(equalTo: topAnchor, constant: 4),
subtitleLabel.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -4)
])
}

// MARK: - Configuration
func set(call: CometChatCallsSDK.CallLog) {
subtitleLabel.text = call.initiatedAt
}
}


SetTrailView

You can customize the tail view for each users item to meet your requirements

You can indeed create a custom TrailView UIView file named CustomTailView for more complex or unique list items.

Afterwards, seamlessly integrate this CustomTrailView UIView file into the .set(trailView:) method within CometChatCallLogs().

let callLogs = CometChatCallLogs()
callLogs.set(trailView: { callLog in
let view = CustomTrailView()
return view
})

Example

Image
import UIKit
import CometChatUIKitSwift
import CometChatSDK
import CometChatCallsSDK

class CustomTrailView: UIView {

// MARK: - Properties
private let tailLabel: UILabel = {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.font = UIFont.systemFont(ofSize: 14, weight: .regular) // Customize font
label.textColor = .darkGray // Customize text color
label.numberOfLines = 1 // Single line
label.textAlignment = .right // Align to the right
return label
}()

// MARK: - Initializers
override init(frame: CGRect) {
super.init(frame: frame)
setupView()
}

required init?(coder: NSCoder) {
super.init(coder: coder)
setupView()
}

// MARK: - Setup
private func setupView() {
addSubview(tailLabel)

// Constraints
NSLayoutConstraint.activate([
tailLabel.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 8),
tailLabel.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -8),
tailLabel.topAnchor.constraint(equalTo: topAnchor, constant: 4),
tailLabel.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -4)
])
}

// MARK: - Configuration
func set(call: CometChatCallsSDK.CallLog) {
tailLabel.text = call.initiatedAt
}
}


info

Ensure to pass and present CometChatCallLogs. If a navigation controller is already in use, utilize the pushViewController function instead of directly presenting the view controller.