robbiehanson / XMPPFramework

An XMPP Framework in Objective-C for Mac and iOS
Other
5.91k stars 2.09k forks source link

mam not sort message from query #1189

Open dan085 opened 4 years ago

dan085 commented 4 years ago
  let xmppDateString = NSDate().xmppDateTimeString

        var fields: [XMLElement] = []
        let start = XMPPMessageArchiveManagement.field(withVar: "end", type: nil, andValue: xmppDateString)
        fields.append(start)

        print(self.mam_info.entityBareId+ServiceName_arroa)
         let value = DDXMLElement(name: NTConstants.value, stringValue: self.mam_info.entityBareId+ServiceName_arroa)
        let child = DDXMLElement(name: NTConstants.field)
        child.addChild(value)
        child.addAttribute(withName: NTConstants.varXMPP, stringValue: NTConstants.with)
        let set = XMPPResultSet(max: 40, before:  "")
        xmmpMessageArchiveManagement!.retrieveMessageArchive(at: XMPPJID(string: self.mam_info.entityBareId+ServiceName_arroa), withFields: fields, with: set)
Abishekt97 commented 4 years ago

hi

I try to retrieve chat history from XMPP. I am also done this code in my project but its not working.

please clarify this issue.

dan085 commented 4 years ago

@Abishekt97 Hi , It worked for me to obtain the historial, I have to review it .. there we could talk about it and help us too

Abishekt97 commented 4 years ago

hi @dverdugo85 thanks for your replay

My code

let xmppDateString = NSDate().xmppDateTimeString var fields: [XMLElement] = [] let start = XMPPMessageArchiveManagement.field(withVar: "end", type: nil, andValue: xmppDateString) fields.append(start) let value = DDXMLElement(name: "value", stringValue: user) let child = DDXMLElement(name: "field") child.addChild(value) child.addAttribute(withName: "var", stringValue: "with") let set = XMPPResultSet(max: 20, before: "") fields.append(child) xmppMAM?.retrieveMessageArchive(at: XMPPJID(string: user), withFields: fields, with: set)

But its not working. please visit my stack overflow question and if you know please answer https://stackoverflow.com/questions/64749713/issue-on-retrieve-the-xmpp-archived-message-from-ejabberd-serverchat-history