【问题标题】:pubnub history api call always returning timetokenpubnub 历史 API 调用总是返回时间令牌
【发布时间】:2016-10-25 22:06:37
【问题描述】:

我在我的 react 本机应用程序中使用 pubnub api 并拨打电话以获取消息历史记录,如下所示:

pubnub.history({
  channel: channel,
  count: 15,
  includeTimetoken: false,
  start: props.lastMessageTimestamp
},
function(status, response){
  console.log(response);
  if (!status.error){
    props.addHistory(response);
  }
}
);

出于某种原因,我总是收到随每条消息返回的时间令牌。默认情况下,即使我指定不返回时间令牌。知道这里发生了什么吗?这是一个示例响应:

{ messages: 
   { messages: 
      [ { timetoken: null,
          entry: 
           { text: 'This is a message',
             user: { _id: 1 },
             createdAt: '2016-10-25T18:56:50.205Z',
             _id: 'temp-id-958468' } },
        { timetoken: null,
          entry: 
           { text: 'Message',
             user: { _id: 1 },
             createdAt: '2016-10-25T18:57:45.810Z',
             _id: 'temp-id-322242' } },
        { timetoken: null,
          entry: 
           { text: 'Test',
             user: { _id: 1 },
             createdAt: '2016-10-25T21:25:43.290Z',
             _id: 'temp-id-806299' } },
        { timetoken: null,
          entry: 
           { text: 'Text',
             user: { _id: 1 },
             createdAt: '2016-10-25T21:34:41.204Z',
             _id: 'temp-id-399187' } } ],
     startTimeToken: 14774207865431668,
     endTimeToken: 14774312812443264 },
  timestamp: undefined }

【问题讨论】:

    标签: javascript react-native pubnub


    【解决方案1】:

    PubNub 历史时间令牌

    这是设计使然 - 新的 SDK v4 响应负载始终返回 timetoken 键,如果 includeTimetoken 为 false(默认值),则它没有值,但可能没有必要排除时间令牌,所以我们可能会弃用includeTimetoken

    存储插件和历史 API 的未来

    我们正在重新设计存储架构和history API,以极大地增强功能和可用性(易用性),默认情况下,我们将在每条消息中返回timetoken,并且没有排除它们的选项。它通常只是你需要的东西,而不是你不需要的东西。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多