【问题标题】:Get openfire Chat History获取 openfire 聊天记录
【发布时间】:2015-05-15 14:16:12
【问题描述】:

我无法从明火中获取历史记录。我正在使用 XMPP 框架

如何从开火存档中获取聊天记录并在nslog中打印历史数据?

【问题讨论】:

标签: ios xmpp openfire browser-history nslog


【解决方案1】:

您需要在 openfire 中启用该选项才能获取聊天记录。 登录openfire,进入群聊,然后进入群聊设置,然后进入历史设置,然后选择显示整个聊天记录选项。

【讨论】:

  • 我已启用显示整个聊天记录选项。但我的问题是在 openfire 本身我可以看到聊天记录和一对一的聊天记录我必须看到的地方请告诉我
  • 您想在 openfire 中查看聊天记录吗?还是在应用中?
  • 在openfire中添加监控服务就可以看到消息历史了
  • 我想在我的应用中查看历史记录:Tarun Khosla
  • 我需要添加任何插件才能看到消息 History : Jaspreet Singh
【解决方案2】:

在加入 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];

【讨论】:

    猜你喜欢
    • 2016-06-26
    • 2015-10-25
    • 1970-01-01
    • 2017-01-09
    • 2011-10-01
    • 1970-01-01
    • 2016-12-04
    • 2013-01-10
    相关资源
    最近更新 更多