Using CoreData to persist chat messages.

1,519 views
Skip to first unread message

seeker44

unread,
Apr 22, 2012, 6:22:49 PM4/22/12
to XMPPFramework
Robbie, et al - Thank you for all the work you've put into this
framework and made available to other developers!

Using your XMPPFramework, I've got a basic iOS chat interface talking
through an OpenFire server to another Jabber client. To get started,
my ChatViewController implementation stores sent and received messages
in an array of NSMutableDictionaries with message body, from, and
timestamp data in each. Now I want to persist the messages.

I see the XMPPUserCoreDataStorageObject class used by
XMPPRosterCoreDataStorage. I am new to CoreData. It seems that here is
where Users are persisted by the framework, or at least by the
iPhoneXMPP example app. I am thinking I need a new CoreData Message
entity/class, and that to the XMPPUserCoreDataStorageObject I can add
a collection attribute into which to save Message objects.

Is this a reasonable approach? I am puzzled by the existence of the
XMPPUserCoreDataStorageObject unreadMessages property. It suggests to
me there might already be a Messages collection I am overlooking?

Any suggestions for best using the framework for persisting chat
messages would be greatly appreciated. Again, thank you for your hard
work and generosity.

Robbie Hanson

unread,
Apr 23, 2012, 11:25:04 AM4/23/12
to xmppfr...@googlegroups.com
I believe many people have rolled their own message storage systems. The 'unreadMessages' property is a reflection of the information stored in whatever custom storage system one may be using. It's used to badge table view rows with an unread count, similar to the SMS app.

I'm currently working on a generic message storage system. You're welcome to take a look. It's actually planned to be a proper implementation of XEP-0136 (message archiving, which will support server-side message archiving as well). In it's current state, however, it's just client side archiving, and will automatically store (to a core data database) all outgoing and incoming messages.

It's in a branch titled "xep-0136", and is up-to-date with the latest code-base.

-Robbie Hanson
> --
> You received this message because you are subscribed to the Google Groups "XMPPFramework" group.
> To post to this group, send email to xmppfr...@googlegroups.com.
> To unsubscribe from this group, send email to xmppframewor...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/xmppframework?hl=en.
>

seeker44

unread,
Apr 24, 2012, 11:15:45 AM4/24/12
to XMPPFramework
Thank you for your quick reply! I checked out the xep-0136 branch and
Xcode complains that XMPPMessageArchiving_Contact_CoreDataObject.m
cannot find "YapXmppManager.h" and "YapUserManager.h". (I cannot find
them anywhere in the project either.). Should I post this on the Git
branch issues?

-seeker44

Robbie Hanson

unread,
Apr 24, 2012, 12:59:03 PM4/24/12
to xmppfr...@googlegroups.com
Oops. Fixing now…

-Robbie Hanson

Robbie Hanson

unread,
Apr 24, 2012, 1:06:40 PM4/24/12
to xmppfr...@googlegroups.com
Pushed fix. Code changes were imported into the repository from another project, and those imports slipped through.

-Robbie Hanson

On Apr 24, 2012, at 8:15 AM, seeker44 wrote:

seeker44

unread,
Apr 24, 2012, 3:58:19 PM4/24/12
to XMPPFramework
Awesome. Thanks for being so responsive! (I bought you a beer!)
-seeker44

ObjColumnist

unread,
May 2, 2012, 11:49:26 AM5/2/12
to XMPPFramework
Judging by the size of XEP-0136 I imagine there is quite a bit of work
left to do in implementing this extension?

Regards

Spencer

On Apr 23, 4:25 pm, Robbie Hanson <robbiehan...@deusty.com> wrote:
> I believe many people have rolled their own message storage systems. The 'unreadMessages' property is a reflection of the information stored in whatever custom storage system one may be using. It's used to badge table view rows with an unread count, similar to the SMS app.
>
> I'm currently working on a generic message storage system. You're welcome to take a look. It's actually planned to be a proper implementation ofXEP-0136(message archiving, which will support server-side message archiving as well).  In it's current state, however, it's just client side archiving, and will automatically store (to a core data database) all outgoing and incoming messages.

Robbie Hanson

unread,
May 2, 2012, 4:56:31 PM5/2/12
to xmppfr...@googlegroups.com
Correct. In it's current state its just local storage. I've been wanting to expand it further with full support for XEP-0136. This is why its still a bit hidden in its own branch.

-Robbie Hanson

nico

unread,
May 20, 2012, 10:21:14 AM5/20/12
to xmppfr...@googlegroups.com
This is a great framework, very nice job Robbie! I was wondering where i should add XMPPArchiving in the code to use it?

>>> To unsubscribe from this group, send email to xmppframework+unsubscribe@googlegroups.com.


>>> For more options, visit this group athttp://groups.google.com/group/xmppframework?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups "XMPPFramework" group.
> To post to this group, send email to xmppfr...@googlegroups.com.

> To unsubscribe from this group, send email to xmppframework+unsubscribe@googlegroups.com.

ObjColumnist

unread,
May 21, 2012, 4:40:06 AM5/21/12
to XMPPFramework
XMPPArchiving is just another XMPPModule so you just need to add it to
the XMPPClient like any other XMPPModule.
> > xmppframewor...@googlegroups.com.
> > >>> For more options, visit this group athttp://
> > groups.google.com/group/xmppframework?hl=en.
>
> > > --
> > > You received this message because you are subscribed to the Google
> > Groups "XMPPFramework" group.
> > > To post to this group, send email to xmppfr...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > xmppframewor...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages