XMPPFramework - Retrieve Archived Messages From Openfire Server
You have to do a request with <retrieve>
(see http://xmpp.org/extensions/xep-0136.html) then you can take a specific time from the received <list>
result. For example:
Send:
<iq type='get' id='pk1'>
<list xmlns='urn:xmpp:archive'
with='piyush@openfire'>
<set xmlns='http://jabber.org/protocol/rsm'>
<max>30</max>
</set>
</list>
</iq>
Receive:
<iq type="result" id="pk1" to="vivek@openfire/iphone">
<list xmlns="urn:xmpp:archive">
<chat with="piyush@openfire" start="2012-07-04T13:16:12.291Z"/>
<chat with="piyush@openfire" start="2012-07-05T08:25:31.555Z"/>
<chat with="piyush@openfire" start="2012-07-05T12:38:24.098Z"/>
<set xmlns="http://jabber.org/protocol/rsm">
<first index="0">15</first>
<last>25</last>
<count>3</count>
</set>
</list>
</iq>
Now you choose one of start
s and send (date and hour must be exacts):
<iq type='get' id='pk1'>
<retrieve xmlns='urn:xmpp:archive'
with='piyush@openfire''
start='2012-07-04T13:16:12.291Z'>
<set xmlns='http://jabber.org/protocol/rsm'>
<max>100</max>
</set>
</retrieve>
</iq>
You will receive something like this (depends the max value -> max=30, bodies=30):
<iq type='result' to='vivek@openfire/iphone' id='page1'>
<chat xmlns='urn:xmpp:archive'
with='piyush@openfire'
start='2012-07-04T13:16:12.291Z'
subject='She speaks!'
version='4'>
<from secs='0'><body>Art thou not Romeo, and a Montague?</body></from>
<to secs='11'><body>Neither, fair saint, if either thee dislike.</body></to>
.
[28 more messages]
.
<from secs='9'><body>How cam'st thou hither, tell me, and therefore? </body>
</from>
<set xmlns='http://jabber.org/protocol/rsm'>
<first index='0'>0</first>
<last>29</last>
<count></count>
</set>
<iq>
XMPPFramework - Unable to Retrieve Chat History from Openfire Server
i dont know if you've realised this, but message archiving is one of the trivial aspects of XMPP. this is one of the most under developed features of XMPP protocol, often leading to lengthy proposal documents that get abandoned because the complexity of it just gets out of hand.
furthermore, you will find that most XMPP servers lack a proper defined message archiving.
if you really want this feature, try ejabbed which has mod_archive
that you can enable.
good luck
Retrieving archive messages using openfire monitoring plugin
Your stanza is correct. But the plugin seems not working.
Openfire Monitoring plugin isn't designed for message archiving. The main purpose of this plugin is for traffic statistic logging & monitoring.
You can take a look on Monitoring Plugin readme page. Message archiving has just added in version 1.3. The message are saved but it's just for logging & monitoring purpose.
I've tried this plugin too & I can't retrieve message history by this plugin.
As a solution, you can install OpenArchive plugin rather than Openfire Monitoring plugin. This plugin is specified for message archiving & retrieval.
I've install OpenArchive 1.6 & it works for me.
My reference: http://community.igniterealtime.org/message/227791#227791
Issue on retrieve the XMPP archived message from ejabberd server(Chat history)
Below code previously i used for message get delegate. Its totally wrong
func xmppStream(_ sender: XMPPStream, willReceive message: XMPPMessage) -> XMPPMessage? {
guard let body = (message.body?.replacingOccurrences(of: "\t", with: String.empty))?.replacingOccurrences(of: "\\s+$", with: String.empty, options: .regularExpression) else {
return nil
}
debugPrint(body)
return message
}
Return the message is necessary for get history messages. previously I return nil value in guard let part
return nil
func xmppStream(_ sender: XMPPStream, willReceive message: XMPPMessage) -> XMPPMessage? {
if let forwardedMessage = message.mamResult?.forwardedMessage{
debugPrint(forwardedMessage)
return message
}
guard let body = (message.body?.replacingOccurrences(of: "\t", with: String.empty))?.replacingOccurrences(of: "\\s+$", with: String.empty, options: .regularExpression) else {
return nil
}
debugPrint(body)
return message
}
Related Topics
Images Can't Contain Alpha Channels or Transparencies
Dashed Line Border Around Uiview
Disabling Nslog for Production in Swift Project
Issue with Unsafepointer<Uint8> in SQLite Project in Swift
Check If User Is Logged into Icloud? Swift/Ios
Does App Store Reject Submission If Nsallowsarbitraryloads Set to Yes
<Input Type="Number"/> Is Not Showing a Number Keypad on iOS
How to Post Nested JSON by Swiftyjson and Alamofire
Webkit Overflow Scrolling Touch CSS Bug on iPad
Wkwebview Fails to Load Images and CSS Using Loadhtmlstring(_, Baseurl:)
Coca Pod Chart Not Appearing (Swift4)
Why Does CSS Background-Size: Cover Not Work in Portrait Mode on iOS
Specifying One Dimension of Cells in Uicollectionview Using Auto Layout
Why Can't I Force Landscape Orientation When Use Uinavigationcontroller
Set a Maximum Number of Children in Firebase