How to get call log list

I want to add one more tab for call log in my app, so please help how can i get the list of call log in java sample app (not using using UI kit).

Hi @avisharma.11,

You can use setCategory(CometChatConstants.CATEGORY_CALL) along with MessageRequestBuilder to get list of calls.

Please provide a method for this.
currently i added this suggested by you
if (messagesRequest == null) {
messagesRequest = new MessagesRequest.MessagesRequestBuilder().setUID(CometChat.getLoggedInUser().getUid())
.setCategory(CometChatConstants.CATEGORY_CALL).build();
}

Hi @avisharma.11,

You can use the messagesRequest object in your code with fetchPrevious() method to get list of call messages.

Please visit the below documentation link to know more.

1 Like

I am getting blank list when i call this method.
MessagesRequest messagesRequest = new MessagesRequest.MessagesRequestBuilder().setUID(CometChat.getLoggedInUser().getUid())
.setCategory(CometChatConstants.CATEGORY_CALL).setLimit(30).build();

    messagesRequest.fetchPrevious(new CometChat.CallbackListener<List<BaseMessage>>() {
        @Override
        public void onSuccess(List <BaseMessage> list) {

            System.out.println(" call...log1"+list);
            for (BaseMessage message: list) {

                System.out.println(" call...log"+message);
            }
        }
        @Override
        public void onError(CometChatException e) {

            System.out.println(" call...log"+e);

        }
    });

Hello @avisharma.11
I see that you are setting the UID as the UID of the logged in user. Please remove the setUID() method from the code and then try again

Thanks

How can i check which call is missed, received and outgoing.

As per suggested by you i using this.

MessagesRequest messagesRequest = new MessagesRequest.MessagesRequestBuilder().
.setCategory(CometChatConstants.CATEGORY_CALL).setLimit(30).build();

messagesRequest.fetchPrevious(new CometChat.CallbackListener<List<BaseMessage>>() {
    @Override
    public void onSuccess(List <BaseMessage> list) {

        System.out.println(" call...log1"+list);
        for (BaseMessage message: list) {

            System.out.println(" call...log"+message);
        }
    }
    @Override
    public void onError(CometChatException e) {

        System.out.println(" call...log"+e);

    }
});

is this method gives call log of logged in user only??

Hi @avisharma.11,

Yes it will return call logs of Logged In user only. You can check the call status of call message using getCallStatus() to identify whether call is missed, incoming or outgoing.

1 Like

currently i getting 30 records, please let me know how can i get all call records and i am not getting getCallstatus() method.

message.getCallstatus() its giving error.

Hi,

There is no way to fetch all call records at once. You can fetch upto 100 records in one request.
And getCallStatus() method is available only in call message. So you need to cast your baseMessage as Call and then use getCallStatus()

Ex:
((Call)message).getCallStatus()

You can refer UI Kit for reference.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.