I haven't used JSQMessageViewController so I spent some time looking through the class definitions. Specifically, I looked at the
DataSource interface definition and this is what I'd do :-
- The data source expects you to return objects conforming to
JSQMessageData and it looks like JSQMessage already conforms to this so you could probably just create instances of this class for your chat messages-Basically, the model for your chat messages view is a messages array of type JSQMessage and this is what you will use as your data source
So the question is how to tie in CBLite with
JSQMessage message array
For that,
a) Register for CB Lite database change notifications (or use live query).
b) When user types message and taps on Send to send message, you will create a document in the CBL database .
c) This should trigger DB change notification
d) When you get a notification that the CBL has changed, you can query for changes and create a corresponding
JSQMessage and add it to your messages array
e) Reload the table. Since the messages array is the data source for your table, it should reflect the changes to messages array
Similarly, when you receive messages via CB replication, when the document is added to CBL , it should trigger a DB change notification and you can follow the steps in (d)-(e) above
Also, the
demo application in that repo looks like a pretty good starting point ...
-Priya