0

I'm having an issue connecting an iOS and Android device with their corresponding QBChat libraries, with the message ID's.

Message objects in Quickblox's iOS library are defined as QBChatMessage objects, that doesn't exist in Quickblox's Android library (which delegates them to a Message class in SMACK library).

The problem is that QBChatMessage class manages message id's as integers, while Message class manages them as Strings. Every message sent from my Android device has a 7-character unique string + a number with the message's position in SMACK chat. When my iPhone receives the message, its ID is a number with the ID from SMACK parsed as much as it could, as in this communication sample (taken from the Android device):

SENT <message id="D64u5-4" to="102521-1799@chat.quickblox.com" from="132505-1799@chat.quickblox.com/Smack" type="chat"><body>{"content":{"text":"hello"},"type":1}</body><thread>7J9230</thread></message>
SENT <message id="D64u5-5" to="102521-1799@chat.quickblox.com" from="132505-1799@chat.quickblox.com/Smack" type="chat"><body>{"content":{"text":"yeah"},"type":1}</body><thread>7J9230</thread></message>
SENT <message id="D64u5-6" to="102521-1799@chat.quickblox.com" from="132505-1799@chat.quickblox.com/Smack" type="chat"><body>{"content":{"text":"test"},"type":1}</body><thread>7J9230</thread></message>

RCV <message id="0" from="102521-1799@chat.quickblox.com" type="chat" xmlns="jabber:client" to="132505-1799@chat.quickblox.com"><body>{"content":{"text":"hello"},"type":1}</body></message>
RCV <message id="1" from="102521-1799@chat.quickblox.com" type="chat" xmlns="jabber:client" to="132505-1799@chat.quickblox.com"><body>{"content":{"text":"yeah?"},"type":1}</body></message>
RCV <message id="2" from="102521-1799@chat.quickblox.com" type="chat" xmlns="jabber:client" to="132505-1799@chat.quickblox.com"><body>{"content":{"text":"yeah!"},"type":1}</body></message>

Message's ID is important for me, in order of database storage. How is this possible? What should I do to solve this issue?

Thanks, kind regards! :)

dinoenri
  • 265
  • 2
  • 8

2 Answers2

0

Daniel, sounds good. Is changing type of QBChatMessages.ID to NSString will solve your issue?

Will do that in next release. If you haven't time to wait - just write with your request to assist@quickblox.com, will make special build of SDK for you

Rubycon
  • 18,156
  • 10
  • 49
  • 70
  • Thank you very much! Changing id in iOS to a NSString would be the easiest and the best solution, in my opinion. However, I managed to solve this issue by myself by managing ids on my own in Android and using SMACK's Message class for communication, instead of communicating with String. – dinoenri Apr 23 '13 at 09:50
0

Below is my Android code for group chat:

    /* Sends messages */
    public void sendChatMessage(String text)
    {
        Message message = muc.createMessage();
        message.setBody(text);
        message.setPacketID("ABC_1");
        muc.sendMessage(message);
    }

    /* Listens for messages */
    public void receiveMessage()
    {
      muc.addMessageListener(new PacketListener() {
                 public void processPacket(Packet packet) 
                 {
                   final Message message = (Message) packet;
                   log.i("packed  id: ", packet.getPacketID());
                   log.i("message id: ", message.getPacketID());
             }
        });
     }

The output I see in logcat is

packet id: null message id: null

Could you please tell me why the IDs are null? Am I missing something here?

TheMan
  • 703
  • 8
  • 11