Skip to main content
Version: v4

Call Logs

Overview

CometChat's Flutter 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 Flutter application.

Fetching Call Logs

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

CallLogRequest callAppSettings = (CallLogRequestBuilder()
..authToken = AppConfig.userAuthToken
..limit = 30
..callCategory = CometChatCallsConstants.callCategoryCall
).build();

CallLogRequestBuilder has the following settings available.

SettingDescription
int limitSpecifies the number of call logs to fetch.
String callTypeSets the type of calls to fetch (audio or video). It accepts following String's as a parameter "video", "audio" & "audio/video"
String callStatusSets the status of calls to fetch (initiated, ongoing, etc.). It accepts following String's as a parameter "ongoing", "busy", "rejected", "cancelled", "ended", "missed", "initiated", "unanswered"
bool hasRecording Sets whether to fetch calls that have recordings.
String callCategorySets the category of calls to fetch (call or meet). It accepts following String's as a parameter "call" & "meet"
String callDirectionSets the direction of calls to fetch. It accepts following String's as a parameter "incoming" & "outgoing"
String uid Sets the UID of the user whose call logs to fetch.
String guidSets the GUID of the user whose call logs to fetch.
String authTokenSets the Auth token of the logged-in user.

Fetch Next

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

CallLogRequest callAppSettings = (CallLogRequestBuilder()
..authToken = CometChat.getUserAuthToken()
..limit = 30
..callCategory = CometChatCallsConstants.callCategoryCall
).build();

callAppSettings.fetchNext(onSuccess: (List<CallLog> callLogs){
debugPrint("Success");
}, onError: (CometChatCallsException e) {
debugPrint("Error");
});

Fetch Previous

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

CallLogRequest callAppSettings = (CallLogRequestBuilder()
..authToken = CometChat.getUserAuthToken()
..limit = 30
..callCategory = CometChatCallsConstants.callCategoryCall
).build();

callAppSettings.fetchPrevious(onSuccess: (List<CallLog> callLogs){
debugPrint("Success");
}, onError: (CometChatCallsException e) {
debugPrint("Error");
});

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 callback listener. Upon success, this function will return a list of call details, as multiple calls can be initiated for one session ID.

String sessionID = "SESSION_ID";
String userAuthToken = CometChat.getUserAuthToken();

CometChatCalls.getCallDetails(sessionID, userAuthToken, onSuccess: (List<CallLog> callLogs) {
debugPrint("Success");
}, onError: (CometChatCallsException e) {
debugPrint("Error");
});

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