Search code examples
historyxmppframeworkchatroommuc

xmpp - how to get room chat history


I am using the iOS xmppframework. I want to get room chat history when needed. Such that there is a button, when click the button, 20 history messages will be received each time.

If I have 100 history messages, I click the button 5 times, then I will get all the history message.

[xmppRoom1 joinRoomUsingNickname:@"myNickname" history:history password:nil];

this method can only used once.


Solution

  • Send history nil and alos update in openfire open your openfire url then click on Group chat > Group Chat setting > your group > history setting

    enter image description here

    XMPPRoomMemoryStorage *roomStorage = [[XMPPRoomMemoryStorage alloc] init];
            XMPPJID *roomJID = [XMPPJID jidWithString:[NSString stringWithFormat:@"%@@conference.51.101.97.21",groupName]];
            XMPPRoom *xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:roomStorage
                                                                   jid:roomJID
                                                         dispatchQueue:dispatch_get_main_queue()];
    
            [xmppRoom activate:xmppStream];
            [xmppRoom addDelegate:self
                    delegateQueue:dispatch_get_main_queue()];
            [xmppRoom joinRoomUsingNickname:xmppStream.myJID.user
                                    history:nil
                                   password:nil];