简体   繁体   中英

How do we retrieve all messages for a dialog without marking them as read in Android QuickBlox SDK?

I am using QuickBlox Android SDK.

While fetching all messages for a dialog, I do not want to mark messages as read. I tried this way but it is not working.

QBRequestGetBuilder customObjectRequestBuilder = new QBRequestGetBuilder();
HashMap<String,Object> map = new HashMap<>();
map.put("mark_as_read",1);
customObjectRequestBuilder.fillParametersMap(map);
ArrayList<QBChatMessage> messages = QBChatService.getDialogMessages(dialog, customObjectRequestBuilder, new Bundle());

Is there any way to achieve this? Or am I missing something?

The correct way to manage this way:

QBRequestGetBuilder customObjectRequestBuilder = new QBRequestGetBuilder();
customObjectRequestBuilder.addRule("mark_as_read", "", 0);

another parameters

ArrayList<QBChatMessage> messages = QBChatService.getDialogMessages(dialog, customObjectRequestBuilder, new Bundle());

With the method markMessagesAsRead. If you only need mark many messages as read. It's possible to mark all messages as read - just don't pass messagesIDs (messagesIDs = null).

StringifyArrayList<String> messagesIDs = "ids";
QBChatService.markMessagesAsRead(dialogId, messagesIDs, new QBEntityCallback<Void>() {
                @Override
                public void onSuccess(Void result, Bundle params) {

                }

                @Override
                public void onError(QBResponseException responseException) {

                }
            });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM