Ios 正在从PubNub服务器检索最新的10条消息

Ios 正在从PubNub服务器检索最新的10条消息,ios,pubnub,Ios,Pubnub,根据最新的PubNub 3.6.2,我使用以下方法检索在通道中发送的最新10条消息: PNDate *now = [PNDate dateWithDate:[NSDate date]]; [PubNub requestHistoryForChannel:self.currentChannel from:nil to:now limit:10 reverseHistory:YES includingTimeToken:YES withCompletionBlock:^(NSArray *retri

根据最新的PubNub 3.6.2,我使用以下方法检索在通道中发送的最新10条消息:

PNDate *now = [PNDate dateWithDate:[NSDate date]];
[PubNub requestHistoryForChannel:self.currentChannel from:nil to:now limit:10 reverseHistory:YES includingTimeToken:YES withCompletionBlock:^(NSArray *retrivedMessages, PNChannel *channel, PNDate *beginDate, PNDate *endDate, PNError *error) {
...}];
我的问题是,在该通道中发送10条消息后,此方法将仅检索第一条10条消息,而不是最近的10条消息。我想使用
from:nil to:now
会一直收到最新的消息,我想知道我是否错过了什么

谢谢达斯皮安主义者

您收到前10条消息的原因是您指定了
reverseehistory:YES
。这具有从最早的消息开始遍历消息历史的效果

例如,如果我的消息队列是:
1,2,3,4,5,6,8,9,10
(其中
1
是最早的消息,
10
是最新的消息)

[PubNub requestHistoryForChannel:self.currentChannel from:nil to:now limit:3反向历史:是,包括TimeToken:YES withCompletionBlock:^(NSArray*RetrievedMessages,PNChannel*channel,PNDate*beginDate,PNDate*endDate,PNError*error){
...}];

应返回:
[1,2,3]

通过设置
reverseehistory:NO
,调用应该是队列中最新的消息

因此,根据前面的示例:

[PubNub requestHistoryForChannel:self.currentChannel from:nil to:now limit:3反向历史:否包括时间标记:YES With CompletionBlock:^(NSArray*RetrievedMessages,PNChannel*channel,PNDate*beginDate,PNDate*endDate,PNError*error){
...}];

应返回:
[8,9,10]

这很好-是的,设置
反转历史是纠正它的最佳方法。