2016-11-05 93 views
2

我们正在为我们的移动聊天应用程序使用ejabberd服务器。 我们正在为我们的IOS应用程序使用IOS XMPP框架(https://github.com/robbiehanson/XMPPFramework从XMPP获取离线消息而无需成为在线

但是我们在执行时遇到问题,我们无法找到解决方案。 我们已经实现了XMPP消息传递的各个方面,除了一件事情之外,所有作品都很好:

虽然我们的应用程序是在后台,但我们的ejabberd服务器向我们发送推送通知以通知我们有关脱机消息。 (仅针对离线消息发送通知)

然后,我们决定实施IOS后台推送通知功能,以在应用程序处于后台时获取脱机消息。

但问题是我们必须成为在线(发送状态)以获取离线消息。 但是,当我们这样做,它创建了2个不良后果:

  1. 谁发送消息看到我们的存在为在线(尽管我们是在后台)
  2. 只是因为我们正在成为网上同时申请的一方由于我们处于在线状态,服务器只能发送离线消息通知,因此我们的服务器无法发送其他人消息的推送通知。

为了解决这个问题,只有我能想到的是,如果有办法从xmpp服务器上检索离线消息而不上网。 有谁知道,如果有没有办法做到这一点与XMPP的框架IOS

[编辑] 让我澄清一下这个问题有点多:

问题不仅仅是多了一个:

问题1 - 推送通知的问题:

1.1 - Server check if the message is sending to an online or offline user. If the user is offline server sends push notification to inform user but if the user is online server doesnt send anything. 
1.2 - When the application is in background and receive notification for offline messages, application become alive(still in background) and become online in order to get offline messages 
1.3 - Because the client became online, server doesnt send the push notifications anymore but the application is still in background so the user cannot be informed about the message he/she received. 

因此为了解决这些我需要找到一种方法,通过不发送接收离线消息的问题网上存在服务器

问题2 - 信息接收问题

2.1 - Server check if the message is sending to an online or offline user. If the user is offline server sends push notification to inform user but if the user is online server doesnt send anything. 
2.2 - When the application is in background and receive notification for offline messages, application become alive(still in background) and become online in order to get offline messages 
2.3 - When the application became online server sends all offline messages to client but doesnt send the total count of offline messages(At least I cannot get it with IOS XMPPFramework) 
2.4 - So I dont know how much longer the client should stay alive in the background because I dont know the total count of offline messages, so after getting 2-3 messages I have to suspend the application in the background. But in that case there might be buggy situations such as XMPP Framework receive the offline message but I suspend the client application before writing it to database etc... 

为了找到解决这些问题:

  1. 我需要找到一种方式来获得唯一1离线消息当我想从服务器
  2. 如果可能我还需要得到这些离线消息,而不会变成在线
+0

有关这个问题的任何想法? – tolgatanriverdi

回答

0

查找到ejabberd_mod_offline_post

  1. 首先配置的客房必须是一个会员制的房间,所有用户添加为成员创建之后它,这样能够得到一个总。
  2. 将上述模块添加到ejabberd模块中。
  3. 实现回调服务来处理回调帖子。

的想法是,当用户脱机:

  • 在一个对一的情况下,offline_message_hook将提高
  • 在MUC情况下,muc_filter_message将提高,任何一个不在场的可用的离线。

将帖子:

我用它16.06。并有在线路中的源代码中的错误:

... 

Body = xml:get_path_s(Stanza, [{elem, list_to_binary("body")}, cdata]), 

... 

Type = xml:get_tag_attr_s(list_to_binary("type"), Packet), 

Body = xml:get_path_s(Packet, [{elem, list_to_binary("body")}, cdata]), 

... 

我通过添加fxml:固定它们,例如 身体= ˚F XML:get_path_s(节中,[{ELEM,list_to_binary( “正文”)},CDATA]),

而对于MUC,离线用户处于 '离线' 字段作为这种格式, 'user1..user2..user3 ..',你需要做的是将它们从字符串中分离出来。

+0

我已经使用mod_offline_post模块( mod_interact)但是我不明白你的意思。创建聊天室之后,我邀请用户加入新创建的组,但除此之外,我不知道如何将它们添加为成员(可以向我发送关于该链接的链接?)。另外我不知道你的意思是将上述模型添加到ejabberd模型中并实现回调服务。你能更具体一点吗? 谢谢 – tolgatanriverdi

+0

mod_interact只支持一对一的离线消息。既然你已经使用它,你知道它是如何工作的。我发布的这个也支持MUC。不要邀请用户加入,而是直接将用户添加到成员列表中。 http://xmpp.org/extensions/xep-0045.html#modifymember – dichen

+0

它是否与最新的ejabberd 16.08版本一起工作。因为我尝试使用mod_offline_post来代替,但即使我成功配置它,它也不起作用(不转发邮件) – tolgatanriverdi

0

我建议你自定义扩展元素添加到您的“背景”的在线状态,例如

<presence ...> 
<source xmlns:="com.foo#background"/> 
</presence> 

那么,客户端,当您收到的存在,不通知,如果扩展元素“source”与xmlns“com.foo#background”存在。

+0

实际上,添加扩展元素并不重要,因为客户端不会发送通知。服务器端检查消息是否是离线消息,它会自动将通知发送给设备,当IOS收到通知时,会自动在设备上显示该消息。所以我需要找到一个解决方案来获得离线消息,而不会变成在线或找到一个方法来获得只有1个离线消息(没有得到所有的消息) – tolgatanriverdi

+0

我没有明白,抱歉。问题是关于“其他人在线即使我在后台上”或其他内容?通过最后的评论,你似乎收到了太多的“离线”消息,你不想获得更多的消息。因此,只需在离线模式下第一次将群聊/聊天聊天室移除,或者实施存储消息但仅显示第一个消息的“等待模式”(true | false)。它在第一次在后台启用自身,在第一次接收并启用队列后禁用显示,然后当轻击发送所有收到的消息发送到您的GUI对象 – MrPk

+0

我编辑了我的问题,因为注释部分不包含那么多字符串 – tolgatanriverdi