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.
While retrieve if you use tag=a-user or set project bucket to a-user you will get values accordingly. I am sure if you project bucket, you won’t say this error and all next time
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.
@iamwsumit 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 )
Yes. You’re right. I forgot about it. Thank for reminding me.
All things are working correctly with both themes. Just need to make it for different timezones.