We are using ejabberd server for our mobile chat application. And we are using IOS XMPP-Framework for our IOS application ( https://github.com/robbiehanson/XMPPFramework)
But we have a problem on implementation that we couldn't find a solution. We've implemented every aspect of XMPP messaging and all works good besides one thing:
While our application is on background, our ejabberd server sends us push notifications to inform us about offline messages. (Only sends notification for offline messages)
Then we've decided to implement the IOS background push notification functionality to get offline messages while the application is on background.
But the problem is we have to become online(send presence) in order to get offline messages. But when we do that it creates 2 unwanted consequences:
- The party who sends the message saw our presence as Online (Even though we are in the background)
- Just because we are becoming online while the application is on background , our server cannot send push notification for other people's messages becuase we are online and server can only send notification for offline messages.
For solving that problem, only thing that I can think of is, if there is a way to retrieve offline messages from xmpp server without becoming online. Does anyone know if Is there any way to do that with XMPP-Framework for ios
[EDIT] Let me clarify the issue a little bit more:
Problems are more than just one:
Problem 1 - Push notification problem:
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.
So In order to fix those problem I need to find a way to receive offline messages by not sending the online presence to server
Problem 2 - Message Receive Problem
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...
In order to find a solution to those problems:
- I need to find a way to get only 1 offline message when I want from server
- If possible I also need to get those offline messages without becoming online