【问题标题】:Using PubNub History Android API使用 PubNub History Android API
【发布时间】:2014-11-06 08:20:45
【问题描述】:

我已经使用pubnub.history(channel, true, 100, new Callback() { ...} 方法并成功收到了我最近的 100 个对话历史记录。回复如下:

[[{"message":"hdjcjcjjckckckckvkckckck","timetoken":14151866297757284},{"message":"nexusS","timetoken":14152599862541295},{"message":"nexusS","timetoken":14152600307899119},{"message":"Qmobile","timetoken":14152600563127702},{"message":"qMobile","timetoken":14152600865145050},{"message":"NexusS","timetoken":14152601034959154},{"message":"qMobile","timetoken":14152601234812083}],14151866297757284,14152601234812083]

但问题是我怎么知道哪条消息属于谁,例如如果 A 发送:nexusS 和 B 发送:Qmobile,那么我怎么能通过这条消息知道。就像没有 ID 或身份号码一样,我可以知道对话消息属于那个特定的人。我正在开发一个应用程序,我想在其中分别显示两个用户的对话,例如 Skype 对话,我们可以通过我们的 TAG 名称轻松确定。

提前致谢。

【问题讨论】:

    标签: android json pubnub


    【解决方案1】:

    简单的解决方案是在消息 JSON 本身中添加一个 senderID。例如:

    {"senderID":"usman", "data":{"color":"red","size":"medium","section":4}}
    

    然后你可以解析senderID。另一种方法是也按频道名称进行隔离。所以你已经知道 channelUsman-iOS 中的所有内容都来自 iOS 上的 Usman。

    杰瑞米

    【讨论】:

    • 感谢您的友好回复。它现在正在工作,我制作了包含字符串、IMEI 的 Json 消息。当它登陆Pubnub时,我可以根据imei比较轻松识别用户。我正在打开另一个关于历史的新线程问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多