Open NagarajuMetavoxx opened 4 years ago
The default room history is not to be relied upon, as most servers lose the messages when they are restarted.
You'll probably want to enable MAM for the rooms to make sure all messages are permanent. You can fetch the room MAM archive by calling
let mam = XMPPMessageArchiveManagement()
mam.activate(xmppStream)
mam.addDelegate( ... )
let formatter = DateFormatter()
formatter.locale = Locale(identifier: "en_US_POSIX")
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZZZZZ"
var fields = [DDXMLElement]()
fields.append(XMPPMessageArchiveManagement.field(withVar: "start", type: "text-single", andValue: formatter.string(from: startDate)))
mam.resultAutomaticPagingPageSize = 150
mam.retrieveMessageArchive(at: room.roomJID, withFields: fields, with: nil)
I've fetched the room MAM and I'm getting the xmpp message from the mam delegate method. Now how I can get the body of the message from the below.
`
`
I have able to fetch the rooms, and able to join the rooms. But, getting only 20 messages. I have also applied the history element.What I'm doing wrong.Can any one help me.
let xmppRoom = XMPPRoom(roomStorage: XMPPRoomHybridStorage.sharedInstance(), jid: XMPPJID(string: roomId!)!) xmppRoom.activate(xmppStream) xmppRoom.addDelegate(self, delegateQueue: DispatchQueue.main) let historyElement = DDXMLElement(name: "history") historyElement.addAttribute(withName: "maxstanzas", stringValue: "1000") xmppRoom.join(usingNickname: userJabberId, history: historyElement)
@devarshi089 found any solution?
@arunpandiyanp 20 messages is a common default of the MUC component on various XMPP servers. You should explicitly configure your XMPP server limits to allow to send more messages
Hi @vitalyster thank you for your reply , this code is working me to fetch all the history chat
let mam = XMPPMessageArchiveManagement()
mam.activate(xmppController.xmppStream)
xmppMAM?.addDelegate(self, delegateQueue: .global(qos: .background))
mam.resultAutomaticPagingPageSize = 150
let roomJID = XMPPJID(string: joinOrCreateRoomString)
mam.retrieveMessageArchive(at: roomJID, withFields: nil, with: nil)
@arunpandiyanp this is a different history storage protocol and it may work and may not work depending on server configuration too
Hi, I'm signing into the app and created the MUC room and joining the room. I'm only getting 20 messages, but in my MUC room have more than 20. What I'm doing wrong, can any one suggest me.
Here is my MUC configuration : -
-(void)JoinMucRoom { NSString subscriberName=@"nagaraj"; //NSLog(@"Room Name ----->%@",[def objectForKey:@"room_name"]); XMPPRoomMemoryStorage _roomMemory = [[XMPPRoomMemoryStorage alloc]init]; NSString roomname = self.groupName; NSString roomExtenction = @"@conference.xxxxxxxxx.com"; NSString roomID = [NSString stringWithFormat:@"%@%@",roomname,roomExtenction]; XMPPJID roomJID = [XMPPJID jidWithString:roomID]; room = [[XMPPRoom alloc] initWithRoomStorage:_roomMemory jid:roomJID dispatchQueue:dispatch_get_main_queue()]; [room activate:self.xmppStream]; [room addDelegate:self delegateQueue:dispatch_get_main_queue()]; [room joinRoomUsingNickname:subscriberName history:nil]; }