获取 openfire 聊天记录
Get openfire Chat History
我无法从开火中获取历史记录。我正在使用 XMPP 框架
如何从open fire archive中获取聊天记录并在nslog中打印历史数据?
您需要在openfire中开启获取聊天记录的选项。
登录openfire,进入群聊,然后进入群聊设置,然后进入历史设置,然后select显示整个聊天记录选项。
在加入 xmpp 组时,您必须编写以下代码以在 xmpp 核心数据库中存储消息。
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()];
在此之后,当您进入特定组时,您必须使用以下代码从 xmpp 核心数据库获取历史记录:-
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];
我无法从开火中获取历史记录。我正在使用 XMPP 框架
如何从open fire archive中获取聊天记录并在nslog中打印历史数据?
您需要在openfire中开启获取聊天记录的选项。 登录openfire,进入群聊,然后进入群聊设置,然后进入历史设置,然后select显示整个聊天记录选项。
在加入 xmpp 组时,您必须编写以下代码以在 xmpp 核心数据库中存储消息。
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()];
在此之后,当您进入特定组时,您必须使用以下代码从 xmpp 核心数据库获取历史记录:-
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];