0
votes

I Successfully implemented group chat using Openfire with XMPP.

Now when User A send message to User B who is offline, So when User B is online how can I retrieve all unread/offline messages from server.

I'm doing this stuff to join the room but it getting all messages from server :

- (void) getJoinRoom
{
    XMPPRoomMemoryStorage *roomStorage = [[XMPPRoomMemoryStorage alloc] init];
    XMPPJID *roomJID = [XMPPJID jidWithString:chatWithUser];

    xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:roomStorage
                                                 jid:roomJID
                                       dispatchQueue:dispatch_get_main_queue()];

    [xmppRoom activate:self.xmppStream];
    [xmppRoom addDelegate:self
            delegateQueue:dispatch_get_main_queue()];

    [xmppRoom joinRoomUsingNickname:self.xmppStream.myJID.user
                            history:nil
                           password:nil];
}

How do I fetch those offline messages ?

1

1 Answers

0
votes

As per XMPP standard, only one-one chat messages are eligible for offline storage, so messages of type="groupchat" are never stored in offline storage in XMPP Servers.

As per MUC XEP if a user goes offline, it doesn't count as a participant of the room any more. So when the user comes online, he will have to join the room by sending presence packet to the room.