【发布时间】:2017-03-19 08:56:28
【问题描述】:
我们正在为我们的移动聊天应用程序使用 ejabberd 服务器。 我们正在为我们的 IOS 应用程序使用 IOS XMPP-Framework (https://github.com/robbiehanson/XMPPFramework)
但是我们在实施过程中遇到了一个问题,我们找不到解决方案。 我们已经实现了 XMPP 消息传递的各个方面,并且除了一件事之外一切都很好:
当我们的应用程序处于后台时,我们的 ejabberd 服务器会向我们发送推送通知,以通知我们有关离线消息的信息。 (仅发送离线消息通知)
然后我们决定实现 IOS 后台推送通知功能,以便在应用程序处于后台时获取离线消息。
但问题是我们必须在线(发送状态)才能获得离线消息。 但是当我们这样做时,它会产生 2 个不良后果:
- 发送消息的一方将我们的存在视为在线(即使我们在后台)
- 仅仅因为我们在应用程序处于后台时在线,我们的服务器无法发送其他人消息的推送通知,因为我们在线,服务器只能发送离线消息的通知。
为了解决这个问题,我能想到的唯一一件事是,是否有一种方法可以从 xmpp 服务器检索离线消息而无需在线。 有谁知道是否有任何方法可以使用 XMPP-Framework for 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 条离线消息
- 如果可能,我还需要在不在线的情况下获取这些离线消息
【问题讨论】:
-
对这个问题有任何想法吗?
标签: ios objective-c xmpp ejabberd xmppframework