I am making a chat app and I am using firebase realtime database to save the messages.
now my problem is, here in the screen shot “b-user” send the message first then “a-user” send message but as firebase is storing data in alphabetic order so they are putting a-user’s message first and if I refresh the app screen a-user’s message is showing first.
how to solve this?
if I can store data in any other more sufficient way then please inform me.
I have one successful and the easiest way which I always implement in my chat app
As we know firebase store data is sequence 1,2,3,4,5 but after 10 it set 11th data at first so just need to create one variable(index no) with 100000000000000000000 or greater length ,length needs to be greater than 20 to 30 length then every time when you store any data use (index no) +10 this is perfect and tested more than 15 times , you can store value with (tag = join “index no” + “username” and your value). If you don’t understand then reply this message I’ll show you blocks.
@Sumit1334 logic will also work but I was doubting that it will may not work at different timezones if you are allowing international chat system (I am not sure , I can be wrong )