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.
Fetch Next
ThefetchNext() method retrieves the next set of call logs.
Response
Response
On Success —
fetchNext() returns an array of CallLog objects:CallLog Array:CallLog Object (each item in array):
initiator Object:receiver Object:participants Array:Participant Object (each item in array):
recordings Array:Recording Object (each item in array):
data Object:data.entities Object:data.entities.initiator Object:data.entities.receiver Object: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.Next Steps
Ringing
Implement a complete calling experience with incoming and outgoing call UI
Call Session
Start and manage call sessions with full configuration options
Recording
Record call sessions for playback and compliance
Standalone Calling
Implement calling without the Chat SDK