I have the same problem discussed in this Question and surprisingly solution doesn't work for me.
I am using ejabberd server and ios xmppframework. there are two clients, A and B.
When A and B are online, A can send message to B successfully. If B is offline, B can receive the message when B is online again. But when B is suddenly/unexpectedly lost connection, such as manually close wi-fi, the message sent by A is lost. B will never receive this message. I guess the reason is that B lost connection suddenly and the server still think B is online. Thus the offline message does work under this condition.
So my question is how to ensure the message that sent by A will be received by B? To ensure there is no messages lost.