2
votes

I am developing a chat application in iOS using XMPP. I have so far successfully implemented and tested a single user chat scenario, i.e. sending, receiving, saving and retrieving messages.

The problem now em facing is that now when handling Multi User Chat scenarios em receiving it but not able to save them using XMPP MessageArchiving hence cant retrieve them either.

Anyone who has gone through this process/problem?

Thank you in advance

2
Hey Ahmed - did you ever get any further with this since August?Scott Corscadden
Yes I've successfully implemented multiuser chat scenario..Ahmed Z.
I had to customize my message packet.. add Addresses tag in it, removed my id from the 'from' tag and replaced it with 'multicast.severname'.. and few more tweaks.Ahmed Z.
@AhmedZ. I have successfully tested one to one chat sending and receiving message but not save and retrive those message using XMPP MessageArchiving it got crash due to unavailability of persistancecordinatorRohit Pathak
@RohitPathak you are asking about single one to one chat?Ahmed Z.

2 Answers

2
votes

Messages with groupchat type may be saved within XMPPRoom.xcdatamodel, you need to initialize the XMPPRoomCoreDataStorage in your xmpp setup like:

XMPPRoomCoreDataStorage *xmppRoomStorage = [[XMPPRoomCoreDataStorage alloc] init];

So, this class implements a method to insert all the messages ROOM within the correct data model (in our case, all the outgoing and incoming messages are saved in XMPPRoom.xcdatamodel).

- (void)insertMessage:(XMPPMessage *)message outgoing:(BOOL)isOutgoing forRoom:(XMPPRoom *)room stream:(XMPPStream *)xmppStream

More XEP-0045 info http://xmpp.org/extensions/xep-0045.html

1
votes

You can use this code for a saving room messages

NSString *xmppRoomJIDString = [NSString stringWithFormat:@"%@@conference.your_host", @"your_room_name"];

XMPPJID *roomJID = [XMPPJID jidWithString:xmppRoomJIDString];

XMPPRoomCoreDataStorage *roomCoreDataStorage = [XMPPRoomCoreDataStorage sharedInstance];

XMPPRoom *xmppRoom = [[XMPPRoom alloc]
            initWithRoomStorage:roomCoreDataStorage
            jid:roomJID
            dispatchQueue:dispatch_get_main_queue()];

[xmppRoom activate:xmppStream];
[xmppRoom addDelegate:self delegateQueue:dispatch_get_main_queue()];

[xmppRoom joinRoomUsingNickname:@"your_nicke_name" history:nil];
[xmppRoom fetchConfigurationForm];