2

I'm using the Quickblox iOS SDK for instant messaging in my app. When a user logs in I retrieve the list of messages. I am trying to retrieve the last N messages. I use extended request parameters as specified in this document: http://quickblox.com/developers/SimpleSample-chat_users-ios#List_chat_messages

This call retrieves the first 100 messages, not the most recent ones. I also checked out the list of parameters to send from here: http://quickblox.com/developers/Chat#Retrieve_messages

Using a combination of the limit and sort parameters still does not give the desired result.

  1. How can I make a request to retrieve the last N messages in a dialog?
  2. How can I load last but N messages? for example, last 100 messages before the most recent 100. Similar to limit 100, but skip 100, in reverse.
Inn0vative1
  • 2,014
  • 3
  • 27
  • 43

2 Answers2

3

//Try this out:

NSMutableDictionary *extendedRequest = [NSMutableDictionary new];
NSDate *now = [NSDate date];
extendedRequest[@"date_sent[lte]"]= @([now timeIntervalSince1970]);
extendedRequest[@"sort_desc"]= @"date_sent";

//get the most recent 50 messages
extendedRequest[@"limit"] = @(50);
[QBChat messagesWithDialogID:self.dialog.ID extendedRequest:extendedRequest delegate:self];
Rubycon
  • 18,156
  • 10
  • 49
  • 70
ikan
  • 31
  • 2
  • @IgorKhomenko i have tried like this. Still last few messages got skipped in the history list. QBChatDialog chatDialog = new QBChatDialog(privateDialog.getDialogId()); QBMessageGetBuilder messageGetBuilder = new QBMessageGetBuilder(); messageGetBuilder.setLimit(50); messageGetBuilder.sortDesc("date_sent"); – Rameshbabu Jul 28 '17 at 14:23
0

I was getting the same issue in Android .

Solved it as following . All you have to do is add a parameter in requestbuilder sortDesc("date_sent");

QBDialog dlg=new QBDialog(str_dialogid);
    QBRequestGetBuilder requestBuilder = new QBRequestGetBuilder();
    requestBuilder.setLimit(10);
    requestBuilder.sortDesc("date_sent");
Sayeed
  • 11
  • 2