0

For Android, a fresh installed app, when open a chat view first time

onChildAdded() callback happens before onDataChange(),

then quit chat view and reopen it again

onChildAdded() callback happens AFTER onDataChange(),

I can reproduce this behavior easily by install/uninstall the app

Is this a known issue for firebase?

By the way, the onDataChange() is registered by addListenerForSingleValueEvent().

Device is Nexus 4, Android version is 4.4.4, Firebase version 2.0.3

harvestli
  • 15
  • 1
  • 3
  • No way to assist here without seeing some code that reproduces the issue. See [creating an mcve](http://stackoverflow.com/help/mcve) – Kato Dec 23 '14 at 17:36

1 Answers1

1

child_added event is fired every time when the app is launched. I believe it's a feature not issue. What you could do here is limit it to last added child and perhaps ignore it for the first time when your app boots up. Or Maybe it will be useful to load last 10 messages and then listen for new one. It's your call.

ref.limit(1).on('child_added', function(s){});
webduvet
  • 4,220
  • 2
  • 28
  • 39
  • See also http://stackoverflow.com/questions/18270995/how-to-retreive-only-new-data and http://stackoverflow.com/questions/19883736/how-to-discard-initial-data-in-a-firebase-db – Kato Dec 23 '14 at 17:36