I’m working on a chatting system, now when two users subscribe to a channel, everything is working as expected, but if user1 terminates the app(I think this means that user1 unsubscribe to the channel) and
user2 sends him a message,user1 will not receive it.
What is the structure to ensure that the user1 receives the message?
flutter sdk.
Hello @adel_kasno
The system providing message reception is addMessageListener - Receiving Unfiltered Messages.
You can get message status - Get Message Status.
this is working when the app not terminated, but if the app terminated it’s never invoked
this will be invoked on sending messages, but I’m talking about the user who is receiving the message…
if the user has the app terminated, no message will be received, so the expected solutions are:
1- when opening the app get old messages.
2- addMessageListener invoked even if app terminated.
and maybe more. do you have a solution?
Hello @adel_kasno
Seems like you are looking for a way to have persisted messaging system.
While RT Messaging works as a PubSub notifications. So to have stored messaged I assume you need to store them somewhere in the DB, let’s say a table with name Messages. On start, your app retrieves all the previous messages and subscribes to the RT channel to get new messages in real-time while it’s running
Does it make sense?
Regards, Vlad
hi @vladimir-upirov
It does make sense but it is a bit expensive, every message I should add it to the table, and the table data will grow up fast, and on every app startup, I should get all messages… is there a way to get subscribers count on a channel, so I’ll be able to reduce its cost and store only messages when the user is offline.
get channel count by realtime or maybe another way to check other user if online
No, there is no way to get subscribers count.
I agree with you that table will grow up, but there might be a timer which clean old messages, or client when receive all the non-read messages can send a request to remove them using bulkDelete.
Ok thank you, I’ll consider this as a solution.
But I was expecting a better solution.
Regards
i actually use it like this.
the table will not grow a lot since you will delete the message when the user connect and receive the message.