Just how persistent are Firebase database observers?

僤鯓⒐⒋嵵緔 提交于 2019-12-23 05:31:05

问题


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:


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.



来源:https://stackoverflow.com/questions/40337765/just-how-persistent-are-firebase-database-observers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!