Quick Reference - Fetch call logs:
Overview
CometChat’s React Native 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 React Native application.Fetching Call Logs
To fetch all call logs in your React Native application, you should use theCallLogRequestBuilder, This builder allows you to customize the call logs fetching process according to your needs.
CallLogRequestBuilder has the following settings available.
| Setting | Description |
|---|---|
setLimit(limit: number) | Specifies the number of call logs to fetch. |
setCallType(callType: 'video' or 'audio') | Sets the type of calls to fetch (call or meet). |
setCallStatus(callStatus: 'ongoing' or 'busy' or 'rejected' or 'cancelled' or 'ended' or 'missed') | Sets the status of calls to fetch (initiated, ongoing, etc.) |
setHasRecording(hasRecording: boolean) | Sets whether to fetch calls that have recordings. |
setCallCategory(callCategory: 'call' or 'meet') | Sets the category of calls to fetch (call or meet). |
setCallDirection(callDirection: 'incoming' or 'outgoing') | Sets the direction of calls to fetch (incoming or outgoing) |
setUid(uid: string) | Sets the UID of the user whose call logs to fetch. |
setGuid(guid: string) | Sets the GUID of the user whose call logs to fetch. |
setAuthToken(authToken: string) | Sets the Auth token of the logged-in user. |
Fetch Next
ThefetchNext() method retrieves the next set of call logs.
Response
Response
On Success —
CallLog Object (each item in array):
Participant Object (each item in array):
Recording Object (each item in array):
fetchNext() returns an array of CallLog objects:CallLog Array:| Parameter | Type | Description | Sample Value |
|---|---|---|---|
| (array) | array | Array of call log objects | See below ↓ |
| Parameter | Type | Description | Sample Value |
|---|---|---|---|
sessionId | string | Unique session identifier | "v1.in.2748663902141719.1772100619..." |
totalAudioMinutes | number | Total audio duration in minutes | 7.65 |
totalVideoMinutes | number | Total video duration in minutes | 0 |
totalDuration | string | Formatted total duration | "00:07:39" |
totalDurationInMinutes | number | Total duration in minutes | 7.65 |
hasRecording | boolean | Whether call has recordings | true |
initiatedAt | number | Unix timestamp when call was initiated | 1772100619 |
startedAt | number | Unix timestamp when call started | 1772100622 |
endedAt | number | Unix timestamp when call ended | 1772101081 |
initiator | object | User who initiated the call | See below ↓ |
receiver | object | User who received the call | See below ↓ |
mode | string | Call mode | "call" |
receiverType | string | Type of receiver | "user" |
status | string | Call status | "ended" |
totalParticipants | number | Total number of participants | 2 |
type | string | Type of call | "audio" |
mid | string | Message ID | "21d6e797-1b44-4a70-be73-d915dba206c7" |
participants | array | List of call participants | See below ↓ |
recordings | array | List of recordings | See below ↓ |
data | object | Additional call data | See below ↓ |
initiator Object:| Parameter | Type | Description | Sample Value |
|---|---|---|---|
uid | string | Unique user identifier | "cometchat-uid-7" |
name | string | Display name of the user | "Henry Marino" |
avatar | string | URL to user’s avatar image | "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-7.webp" |
receiver Object:| Parameter | Type | Description | Sample Value |
|---|---|---|---|
uid | string | Unique user identifier | "cometchat-uid-6" |
name | string | Display name of the user | "Ronald Jerry" |
avatar | string | URL to user’s avatar image | "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-6.webp" |
participants Array:| Parameter | Type | Description | Sample Value |
|---|---|---|---|
| (array) | array | Array of participant objects | See below ↓ |
| Parameter | Type | Description | Sample Value |
|---|---|---|---|
uid | string | Unique user identifier | "cometchat-uid-6" |
name | string | Display name of the user | "Ronald Jerry" |
avatar | string | URL to user’s avatar image | "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-6.webp" |
totalAudioMinutes | number | User’s audio duration in minutes | 7.65 |
totalVideoMinutes | number | User’s video duration in minutes | 0 |
totalDurationInMinutes | number | User’s total duration in minutes | 7.65 |
isJoined | boolean | Whether user joined the call | true |
state | string | Participant state | "ended" |
deviceId | string | Device identifier | "2b1d0b90-b6b9-4c1c-9899-9bf4effe549f@..." |
joinedAt | number | Unix timestamp when user joined | 1772100622 |
leftAt | number | Unix timestamp when user left | 1772101081 |
mid | string | Message ID | "21d6e797-1b44-4a70-be73-d915dba206c7" |
recordings Array:| Parameter | Type | Description | Sample Value |
|---|---|---|---|
| (array) | array | Array of recording objects | See below ↓ |
| Parameter | Type | Description | Sample Value |
|---|---|---|---|
rid | string | Recording ID | "noujausedimwfhwl" |
recording_url | string | URL to download the recording | "https://recordings-in.cometchat.io/..." |
duration | number | Recording duration in minutes | 1.045 |
startTime | number | Unix timestamp when recording started | 1772100632 |
endTime | number | Unix timestamp when recording ended | 1772100634 |
data Object:| Parameter | Type | Description | Sample Value |
|---|---|---|---|
entities | object | Entity details for the call | See below ↓ |
data.entities Object:| Parameter | Type | Description | Sample Value |
|---|---|---|---|
initiator | object | Initiator entity wrapper | See below ↓ |
receiver | object | Receiver entity wrapper | See below ↓ |
data.entities.initiator Object:| Parameter | Type | Description | Sample Value |
|---|---|---|---|
entity | object | User entity details | {"uid": "cometchat-uid-7", "name": "Henry Marino", "avatar": "..."} |
data.entities.receiver Object:| Parameter | Type | Description | Sample Value |
|---|---|---|---|
entity | object | User entity details | {"uid": "cometchat-uid-6", "name": "Ronald Jerry", "avatar": "..."} |
Fetch Previous
ThefetchPrevious() method retrieves the previous set of call logs.
Response
Response
On Success —
fetchPrevious() returns an array of CallLog objects with the same structure as fetchNext(). See fetchNext Response for the complete object structure.Get Call Details
To retrieve the specific details of a call, use thegetCallDetails() method. This method requires the Auth token of the logged-in user and the session ID along with a callback listener.
Response
Response
On Success —
getCallDetails() returns an array of CallLog objects with the same structure as fetchNext(). See fetchNext Response for the complete object structure.Replace
"SESSION_ID" with the ID of the session you are interested in.Best Practices
Use pagination for large call histories
Use pagination for large call histories
Always use
fetchNext() with a reasonable setLimit() value (e.g., 20-30) rather than fetching all logs at once. This improves performance and reduces memory usage, especially for users with extensive call histories.Filter logs for specific views
Filter logs for specific views
Use the builder’s filter methods (
setCallType, setCallStatus, setCallDirection) to fetch only the logs relevant to your current UI view. For example, show only missed calls in a “Missed” tab rather than filtering client-side.Cache call logs locally
Cache call logs locally
Consider caching fetched call logs locally to reduce API calls and improve load times. Use
fetchNext() to load newer logs and fetchPrevious() for older ones as the user scrolls.Troubleshooting
Call logs return empty
Call logs return empty
Verify that the
authToken passed to setAuthToken() is valid and belongs to the logged-in user. Also check that calls have actually been made — call logs are only generated after a call session completes.fetchNext returns the same results
fetchNext returns the same results
Ensure you’re reusing the same
callLogRequestBuilder instance for pagination. Creating a new builder resets the cursor, causing the same page to be fetched repeatedly.getCallDetails returns no data
getCallDetails returns no data
Confirm the
sessionID is correct and corresponds to a completed call. Active or in-progress calls may not have full details available yet.