/ SDKs / React Native
SDKs
Calls SDKs React Native v1
Calls SDKs React Native
Calls SDKs
React Native
Version 1

Retrieve call history

Copy link

Sendbird server automatically stores information about calls. For ended calls, you can retrieve information such as user IDs of callees and callers, call history, and the end results.


Retrieve a call information

Copy link

To retrieve information on local or remote users, use directCall.localUser and directCall.remoteUser properties.


Retrieve call history

Copy link

To retrieve information calls such as call history of a user, use the DirectCallLogListQuery instance. You can use parameters like myRole and endResults to specify your search.

import { DirectCallEndResult, DirectCallLogListQuery, SendbirdCalls } from '@sendbird/calls-react-native';

const useCallHistory = () => {
 const [history, setHistory] = useState<DirectCallLog[]>([]);
 const query = useRef<DirectCallLogListQuery>();

 useEffect(() => {
   const effect = async () => {
     query.current = await SendbirdCalls.createDirectCallLogListQuery({
       myRole: 'ALL',
       endResults: [
         DirectCallEndResult.COMPLETED,
         DirectCallEndResult.CANCELED,
         DirectCallEndResult.DECLINED,
         DirectCallEndResult.DIAL_FAILED,
         DirectCallEndResult.ACCEPT_FAILED,
       ],
       limit: 20,
     });

     const data = await query.current.next();
     setHistory(data);
   };

   effect();

   return () => {
     query.current.release();
   };
 }, []);

 return {
   next: async () => {
     if (query.hasNext) {
       const data = await query.current.next();
       setHistory((prev) => prev.concat(...data));
     }
   },
   history,
 };
};