Recently, I try to build a chat app in android with XMPP! I installed Ejabberd
, and with connection
, I can chat with another user with my android app! But now, I have an issue in retrieve chat logs history! I mean that I don't know how to get chat history with Asmack
and Ejabberd
. I tried reading the smack
document, however, I can find nothing!! So, anyone has any suggestion to get chat history with asmack and Ejabberd? Thank very much!

- 8,052
- 9
- 46
- 86
1 Answers
Ejabberd does not necessarily save chat history by default, since that can be a potentially very expensive task. Nor is it built into the core part of the server. There are modules available such as mod_archive that can installed/enabled that would allow you to save some chat history, but as chat history is not part of the core XMPP spec, there is no "standard" way to do it, so it would only work when connecting to your own servers. What you might consider doing instead is archiving your chat history yourself locally. You will notice that this is what most desktop XMPP clients do. Enabling mod_offline would allow you to receive message that were sent to you when you were offline. But there is no special method for retrieving them, they just arrive when you log in.

- 1,889
- 2
- 22
- 27
-
If I install `JLogger` for Ejabberd to save chat history, how I can retrieve it? – Kingfisher Phuoc Sep 10 '12 at 01:22
-
The XEP [xmp-0316](http://xmpp.org/extensions/xep-0136.html) covers archiving and retrieval, pretty much what you need. You would need to extend asmack to use this, it does not appear Smack currently supports this extension. [Smack extensions](http://www.igniterealtime.org/builds/smack/docs/latest/documentation/extensions/index.html). This module [mod_archive](http://www.ejabberd.im/mod_archive) would provide support for this on the server side. Some more searching for extensions may yield someone who has already done this. – zenWeasel Sep 10 '12 at 14:43
-
@zenWeasel please check out this question http://stackoverflow.com/questions/27125713/how-to-retrieve-one-to-one-chat-history-from-openfire-using-asmack-android – Mahi Nov 26 '14 at 06:39