如何在安卓中从明火中检索聊天记录



我有一个聊天应用程序,我想在其中检索两个用户之间的聊天记录,我有一个用于检索聊天消息的节,那就是......

    <iq type='get' id='pk1'>
<list xmlns='urn:xmpp:archive'
with='shrey27@sys1-pc'>
<set xmlns='http://jabber.org/protocol/rsm'>
<max>30</max>
</set>
</list>
</iq>

现在,我的问题是如何将此节触发到服务器,以便获得响应。我已经安装了消息存档插件,并且消息得到了完美的存储。任何建议都是有益的......提前谢谢!!

NSXMLElement *iQ = [NSXMLElement elementWithName:@"iq"];
[iQ addAttributeWithName:@"type" stringValue:@"get"];
[iQ addAttributeWithName:@"id" stringValue:@"987654321"];
NSXMLElement *list = [NSXMLElement elementWithName:@"list"];
[list addAttributeWithName:@"xmlns" stringValue:@"urn:xmpp:archive"];
[list addAttributeWithName:@"with" stringValue:@"bhushan@mydomain.com"];

NSXMLElement *set = [NSXMLElement elementWithName:@"set"];
[set addAttributeWithName:@"xmlns" stringValue:@"http://jabber.org/protocol/rsm"];
NSXMLElement *max = [NSXMLElement elementWithName:@"max"];
[max addAttributeWithName:@"xmlns" stringValue:@"http://jabber.org/protocol/rsm"];
max.stringValue = @"30";
[set addChild:max];
[list addChild:set];
[iQ addChild:list];
[[[self appDelegate] xmppStream] sendElement:iQ];

你可以这样打电话。希望这对:)有所帮助

最新更新