XMPPFramework - Retrieving Openfire Message Archives

后端 未结 4 695
醉梦人生
醉梦人生 2020-12-30 17:40

Spent hours trying to solve this problem and I\'m stumped!

Trying to grab the Chat History between 2 users on my OpenFire server and I read that I plugin was needed

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-30 18:25

    When you mention start tag in the request then it matches with the chat having the exact time stamp that's why it returns error code '404' or '500'. I ommited start tag from my request and wrote following code which returns whole chat history with the user.

    NSXMLElement *iq1 = [NSXMLElement elementWithName:@"iq"];
    [iq1 addAttributeWithName:@"type" stringValue:@"get"];
    [iq1 addAttributeWithName:@"id" stringValue:@"pk1"];
    
    NSXMLElement *retrieve = [NSXMLElement elementWithName:@"retrieve" xmlns:@"urn:xmpp:archive"];
    
    [retrieve addAttributeWithName:@"with" stringValue:@"rahul@vishals-mac-pro.local"];
    NSXMLElement *set = [NSXMLElement elementWithName:@"set" xmlns:@"http://jabber.org/protocol/rsm"];
    NSXMLElement *max = [NSXMLElement elementWithName:@"max" stringValue:@"100"];
    
    [iq1 addChild:retrieve];
    [retrieve addChild:set];
    [set addChild:max];
    [[[self appDelegate] xmppStream] sendElement:iq1]; 
    

    Here this will return whole chat history in XML response between user Rahul and the user currently logged in.

    For more detailed info please refer this blog http://question.ikende.com/question/363439343236313430

提交回复
热议问题