Just how persistent are Firebase database observer

2019-06-11 15:04发布

I decided to run a test on the XCode iOS simulator to see if an observer to a location in the Firebase database would continue to fire even when the app is in the background. Turns out it does, but I am wondering if this is indefinite until the app terminates or if it will actually stop after some time. It's been a very long time and the observers still fires whenever I manually update the value in the database that the observer is looking at. Also note that I don't have any background modes enabled in my app's capabilities, so it seems that the observer can persist in background mode despite no explicit background modes of any kind.

On the one hand I am very glad that the observer stays on in background as this is helpful to me, but I am a bit anxious to know why this is allowed to happen as iPhone is generally quite conservative by default when it comes to doing stuff in the background.

1条回答
该账号已被封号
2楼-- · 2019-06-11 15:48

While the listener may stay active in your single test case, you should not rely on Firebase Database listeners for background data delivery.

The listener stays active as long as the connection stays open. It is up to the operating system to determine when it closes the connection. There is a good chance that the iOS emulator has different behavior in this case than a physical device would have.

查看更多
登录 后发表回答