After googling and searching the documentation, all I got was offlinemanager to receive messages offline.
But it does not work in asmack or maybe in smack.It always returns 0 message.
Finally, when I saw the logs, I found that every tie, when I logged in, received a lot of responses on the chat server, which also contains an offline message, but with a message tag, not an offline message tag. So, I finally found
You can receive offline messages from it by directly installing the packet listener after logging in. As below, you must implement the packet listener after the login method.
PacketFilter filter = new MessageTypeFilter(Message.Type.chat); this.connection.addPacketListener(new PacketListener() { public void processPacket(Packet packet) { Message message = (Message) packet; if (message.getBody() != null) { String fromName = StringUtils.parseBareAddress(message .getFrom()); Log.i("XMPPClient", "Got text [" + message.getBody() + "] from [" + fromName + "]"); if (fromName.equalsIgnoreCase(matchUserJabberId + "server name")) {
Hope this helps a lot of people find work for offline messaging sooner since I spent more time getting it.
source share