Reputation: 193
We're making an app that will have some chat functionality and we're using the SendBird Android SDK to achieve this.
When the user logs in, we query SendBird for that user's GroupChannels, this returns a list of channels that the user is currently on. We wish to be able to persist this list.
Currently in the app, we use TinyDb to persist some data. However this is not possible with the list of GroupChannels because of this error:
Unable to invoke no-args constructor for com.sendbird.android.BaseMessage Register an InstanceCreator
So we also tried using an ORM library, Realm for Android. However this requires that we change SendBird classes to extend RealObject and we prefer not to tinker with SendBird's classes.
So I guess the real question is, how can we store/persist a list of objects that don't belong to us(SendBird classes).
Any help would be greatly appreciated.
Upvotes: 1
Views: 414
Reputation: 2084
Sendbird now has SyncManager add-on that you can use. This automatically caches the channels and messages.
Upvotes: 0
Reputation: 116
Serialization was added recently. The caching data section in the documentation provides a bit of demonstration.
Basically, you would use these methods to serialize and deserialize messages and channels.
byte[] baseMessage.serialize()
BaseMessage BaseMessage.buildFromSerializedData(byte[] data)
byte[] baseChannel.serialize()
BaseChannel BaseChannel.buildFromSerializedData(byte[] data)
Then, store the serialized data in a local database (e.g. SQLite or Realm) and update it when you receive a new message, or when a new channel is created.
Upvotes: 1
Reputation: 31
Currently, SendBird does not support local database and serialization officially.
We are aware of the inconvenience you are experiencing, so finding some ways to mitigate it.
I'll keep you posted about this issue.
Upvotes: 0