Group Joining Xmpp : Getting all messages every-time after joined group.

Hello,

After deep look on group joining method of XMPP, we found one solution is describe here:

let  objXmppStream =  XMPPStream()

let objGroup = “YourGroupname@YourXMPPHOST”

let roomStorage = XMPPRoomMemoryStorage()

 let roomJID = XMPPJID.jidWithString(objGroup)

 let objXmppChatRoom = XMPPRoom(roomStorage: roomStorage, jid: roomJID, dispatchQueue: dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0))

 objXmppChatRoom.activate(XMPPHelper.sharedInstance.objXmppStream)

 objXmppChatRoom.fetchConfigurationForm()

 let history = DDXMLElement.init(name: “history”)

   var strSince =  “2017-02-12 08:33:12 5635”    For : “yyyy-MM-dd’T’HH:mm:ssZZZZZ” 

Here the date is “2017-02-12 08:33:12 5635” picked from last message time which you received lastly from that particular group.

 history.addAttributeWithName(“since”, stringValue: strSince)

“Since” keyword is define limit for group messages which returns after successfully joining of group.

objXmppChatRoom.joinRoomUsingNickname(XMPPHelper.sharedInstance.myXMPPId(), history: history )

objXmppChatRoom.addDelegate(self, delegateQueue: dispatch_get_main_queue())

Thanks & Best Regards.

You may also like

Leave a Reply