androidxmppchatopenfiregroupchat

How to get offline message of group chat from Openfire


Is any way in xmpp that i get offline message of MultiUserChat, when my user login and join room.

I want implement group chat like WhatsApp, Is any other way to implement this please suggest

Thanks in advance


Solution

  • At least in ejjaberd when you enter the chat group, you have to enter your last timestamp, given that timestamp you will receive the messages from that moment.

    Save the timestamp from your last message, and when you enter to your room, like the following:

     MultiUserChat muc = new MultiUserChat(mConnection, room_name);
                    Log.d(TAG, "JOINING => " + room_name);
    
                    DiscussionHistory history = new DiscussionHistory();
                    if (mLastMessageDate == null)
                        history.setMaxStanzas(300);
                    else
                        history.setSince(mLastMessageDate); //timestamp from your last message
    
     muc.join(mNickName, null, history,
                                SmackConfiguration.getDefaultPacketReplyTimeout());
    

    Hope it helps