Skip to main content
Version: v4

Call Logs

Overview

CometChat's iOS Call SDK provides a comprehensive way to integrate call logs into your application, enhancing your user experience by allowing users to effortlessly keep track of their communication history. Call logs provide crucial information such as call duration, participants, and more.

This feature not only allows users to review their past interactions but it also serves as an effective tool to revisit important conversation details. With the flexibility of fetching call logs, filtering them according to specific parameters, and obtaining detailed information of individual calls, application developers can use this feature to build a more robust and interactive communication framework.

In the following sections, we will guide you through the process of working with call logs, offering a deeper insight into how to optimally use this feature in your iOS application.

Fetching Call Logs

To fetch all call logs in your iOS application, you should use the CallLogRequestBuilder, This builder allows you to customize the call logs fetching process according to your needs.

var callLogRequest = CometChatCallsSDK.CallLogsRequest.CallLogsBuilder()
.set(authToken: CometChat.getUserAuthToken())
.set(limit: 30)
.set(callCategory: .call)
.build()

CallLogRequestBuilder has the following settings available.

SettingDescription
set(limit: Int)Specifies the number of call logs to fetch.
set(callType: CallType)Sets the type of calls to fetch (call or meet).
set(callStatus: CallStatus)Sets the status of calls to fetch (initiated, ongoing, etc.)
setg(hasRecording: HasRecording)Sets whether to fetch calls that have recordings.
set(callCategory: CallCategory)Sets the category of calls to fetch (call or meet).
set(callDirection: CallDirection)Sets the direction of calls to fetch (incoming or outgoing)
set(uid: String)Sets the UID of the user whose call logs to fetch.
set(guid: String)Sets the GUID of the user whose call logs to fetch.
set(authToken: String)Sets the Auth token of the logged-in user.

Fetch Next

The fetchNext() method retrieves the next set of call logs.

var callLogRequest = CometChatCallsSDK.CallLogsRequest.CallLogsBuilder()
.set(authToken: CometChat.getUserAuthToken())
.set(limit: 30)
.set(callCategory: .call)
.build()

callLogRequest.fetchNext() { [weak self] callLogs in
print("fetchNext success")
} onError: { [weak self] error in
print("fetchNext failed with error; \(error.errorDescription)")
}

Fetch Previous

The fetchPrevious() method retrieves the previous set of call logs.

var callLogRequest = CometChatCallsSDK.CallLogsRequest.CallLogsBuilder()
.set(authToken: CometChat.getUserAuthToken())
.set(limit: 30)
.set(callCategory: .call)
.build()

callLogRequest.fetchPrevious() { [weak self] callLogs in
print("fetchPrevious success")
} onError: { [weak self] error in
print("fetchNext failed with error; \(error.errorDescription)")
}

Get Call Details

To retrieve the specific details of a call, use the getCallDetails() method. This method requires the Auth token of the logged-in user and the session ID along with a success and error callback. Upon success, this function will return a list of call details, as multiple calls can be initiated for one session ID.

var sessionID = "SESSION_ID";
CometChatCalls.getCallDetail(authToken: CometChat.getUserAuthToken(), sessionID: sessionID) { callLogs in
// Handle the fetched call details
} onError: { error in
// Handle the error
}

Note: Replace "SESSION_ID" with the ID of the session you are interested in.