Quickblox消息传递获取最后n条消息 [英] Quickblox messaging fetch last n messages
问题描述
我在我的应用中使用Quickblox iOS SDK进行即时消息传递。当用户登录时,我检索消息列表。我正在尝试检索最后N条消息。我使用本文档中指定的扩展请求参数:
http:// quickblox。 com / developers / SimpleSample-chat_users-ios#List_chat_messages
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
此调用检索前100条消息,而不是最新消息。
我还查看了要从此处发送的参数列表:
http:// quickblox.com/developers/Chat#Retrieve_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.
- 如何在对话框中提出检索最后N条消息的请求?
- 如何加载最后但是N条消息?例如,在最近的100之前的最后100条消息。类似于限制100,但是反过来跳过100。
推荐答案
//试试这个:
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];
这篇关于Quickblox消息传递获取最后n条消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!