1

I am unable to get the history from open fire. I am using XMPP Framework

How to get chat history from open fire archive and print the history data in nslog?

jmm
  • 1,044
  • 2
  • 12
  • 38
Karthik
  • 21
  • 7
  • possible duplicate of [Smack API - Read Chat Histroy from Openfire Server](http://stackoverflow.com/questions/6635034/smack-api-read-chat-histroy-from-openfire-server) – legoscia May 15 '15 at 14:30
  • Hi Chiristian I can see all history in server archive file , My question is how to get those details programmatically to list in table – Karthik May 18 '15 at 08:48

2 Answers2

1

You need to enable the option in openfire to get chat history. Login on openfire, Go to group chat, then go to group chat settings, then go to history settings and then select show entire chat history option.

Tarun Khosla
  • 96
  • 2
  • 9
1

On Join xmpp group you have to write below code for store message in xmpp core database.

storage = [XMPPMessageArchivingCoreDataStorage   sharedInstance];
moc = [storage mainThreadManagedObjectContext];
XMPPMessageArchiving *xmppMessageArchivingModule = [[XMPPMessageArchiving alloc] initWithMessageArchivingStorage:storage];
[xmppMessageArchivingModule setClientSideMessageArchivingOnly:YES];
[xmppMessageArchivingModule activate:xmppStream];
[xmppMessageArchivingModule addDelegate:self delegateQueue:dispatch_get_main_queue()];

after this when you enter in particular group you have to get history from xmpp core database using below code:-

XMPPMessageArchivingCoreDataStorage *_xmppMsgStorage = [XMPPMessageArchivingCoreDataStorage sharedInstance];
NSManagedObjectContext *moc = [_xmppMsgStorage mainThreadManagedObjectContext];
NSEntityDescription *entityDescription = [NSEntityDescription entityForName:@"XMPPMessageArchiving_Message_CoreDataObject"                                                   inManagedObjectContext:moc];
NSFetchRequest *request = [[NSFetchRequest alloc]init];
[request setEntity:entityDescription];
NSError *error;
NSString *predicateFrmt = @"bareJidStr == %@";
NSPredicate *predicate = [NSPredicate predicateWithFormat:predicateFrmt, [NSString stringWithFormat:@"%@%@",GroupName,GROUP_CHAT_DOMAIN]];
request.predicate = predicate;
NSArray *messages = [moc executeFetchRequest:request error:&error];
Parthpatel1105
  • 541
  • 6
  • 17