2
votes

I am developing ios messaging app and I used XMPPFramework.

This XMPPFramework supports XEP-0313 Message Archive Management.

I have enabled Monitoring Service on openfire and it's archiving messages.

I want to retrieve archived messages from the server to iOS app. I researched on google and StackOverflow but nothing found helpfull resources regarding how to retrieve archived messages and save it to the core data(Used by XMPPFramework by default).

I know about this StackOverflow answer it shows me how to retrieve the messages via IQ stanza from the XMPP but I want to retrieve messages directly via this XMPPFramework which already supports but I don't know how to implement? I want to retrieve all conversation which happened after particular date between two users.

Any help will be highly appreciated thank you in advance and sorry for my bad English.

1

1 Answers

0
votes

Hope it is not late answering as I had the same issue. First have a look at the :https://xmpp.org/extensions/xep-0313.html#entities You have xml examples, and you need to implement the XMPPFramework to build such messages. Here is my example:

let query = DDXMLElement.init(name: "query", xmlns: "urn:xmpp:mam:2")

let x = DDXMLElement.init(name: "x", xmlns: "jabber:x:data")
x.addAttribute(withName: "type", stringValue: "submit")


let f1 = DDXMLElement.init(name: "field")
f1.addAttribute(withName: "var", stringValue: "FORM_TYPE")
f1.addAttribute(withName: "type", stringValue: "hidden")
let f1value = DDXMLElement.init(name: "value")
f1value.stringValue = "urn:xmpp:mam:2"

let f2 = DDXMLElement.init(name: "field")
f2.addAttribute(withName: "var", stringValue: "start")

let f2value = DDXMLElement.init(name: "value")
f2value.stringValue = "2010-06-07T00:00:00Z"

f1.addChild(f1value)
f2.addChild(f2value)
x.addChild(f2)
x.addChild(f1)
query.addChild(x)

let iq :XMPPIQ = XMPPIQ(iqType: XMPPIQ.IQType.set, to: someJID, elementID: "someId", child: query)
 print(iq)
self.xmppController?.xmppStream.send(iq)