ref.queryOrdered(byChild: "timestamp").queryStarting(atValue: startTime).observe(.childAdded, with:
{
....
// do work for the messages, print, save to storage, etc.
....
// save startTime to storage for next open.
startTime = max(timeOfSnapshot, startTime)
saveToStorage(startTime)
}
2)
Client A write message 1 to server with ServerValue.timestamp().
Client B write message 2 to server with ServerValue.timestamp().
Client C write message 3 to server with ServerValue.timestamp().
Client B has low speed wifi.
So, finally. Server data saved like <figure-2>
<figure-2>
text : "Message 1", timestamp : 100000001
text : "Message 3", timestamp : 100000002
text : "Message 2", timestamp : 100000003
As my listener's code, i keep messages on storage and next listening timestamp for preventing downloading duplicated messages.
In this case.
Does Firebase always guarantee to trigger callback in order as like below?
Message 1
Message 3
Message 2
If it is not guaranteed, my strategy is absolutely wrong.
For example, some client received messages as like below.
Message 2 // the highest timestamp.
// app crash or out of storage
Message 3
Message 1
The client do not have chance to get message 3, 1 anymore.
I have searched stack overflow and google and read official documents many times. However, i could not find the clear answer.
I have almost spent one week for this. Please give me piece of advice.
--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/7d35643c-045e-48f2-8b72-6a12e9f7f011%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/CADypTEZD-AMWBqcqc23bOOKY1FrDtna6-Rj3EzjpPpaU8JJP6w%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/CAKFF5G4gH9tpPMLMPU0t5_6zJcRGmtnEZUTq7gYm0evCKwXqtw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/ef80de1c-5bf6-430a-81fa-5aae25c8aca2%40googlegroups.com.