ApplozicConversation.getMessageListForContact() limit result size

81 Views Asked by At

I want to retrive messages for contact when i call this function

ApplozicConversation.getMessageListForContact(getAppContext(), contact.getContactIds(), null, new MessageListHandler() {
            @Override
            public void onResult(List<Message> messageList, ApplozicException e) {
                if (e == null) {
                    listOfMessages.addAll(0, messageList);
                    listener.onResult(messageList, e);
                } else {
                    listener.onResult(null, e);
                }
            }
        });

messageList size is 235 i need to do pagination how can i limit result size ? i'm using following SDK version for Android.

com.applozic.communication.message:mobicomkit:5.34

1

There are 1 best solutions below

0
On

Unfortunately, The limit in fetching message restriction is not there however we will think about adding it.

For now, You can use the workaround to import the source code By downloading the Applozic-Android-SDK from the GitHub project this link: https://github.com/AppLozic/Applozic-Android-SDK

Next, import the module mobicomkit from the downloaded GitHub project while importing it will show mobicomkit and mobicommons select both.

then in your app Build.gradle file add api project(':mobicomkit') and make sure you remove the gradle dependency com.applozic.communication.message:mobicomkit:5.34 from your build.gradle file

Next, you can open the file MessageDatabaseService.java file and find the method

public List<Message> getMessages(Long startTime, Long endTime, Contact contact,  Channel channel, Integer conversationId) {

then you will see the Cursor query there you can add the limit as below

 Cursor cursor = db.query("sms", null, structuredNameWhere, structuredNameParamsList.toArray(new String[structuredNameParamsList.size()]), null, null, "createdAt asc limit 200");