I am creating an Ionic 2 app with firebase and I need a way to listen to database changes (specifically on child_added) when the app is closed (I.e. in foreground,background and killed)
我正在使用firebase创建一个Ionic 2应用程序,我需要一种方法来监听应用程序关闭时的数据库更改(特别是在child_added上)(即前景,背景和被杀死)
Basically, I want to use WebRTC to make calls within the app like whatsapp and I am following this post - https://websitebeaver.com/insanely-simple-webrtc-video-chat-using-firebase-with-codepen-demo
基本上,我想使用WebRTC在应用程序内进行调用,如whatsapp,我正在关注这篇文章 - https://websitebeaver.com/insanely-simple-webrtc-video-chat-using-firebase-with-codepen-demo
However, the only thing that puzzles me is how it will work when the app is closed. Can anyone please help me understand?
然而,唯一让我感到困惑的是它在应用程序关闭时的工作方式。有人可以帮我理解吗?
Thanks!
谢谢!
1 个解决方案
#1
0
It's not possible to actively listen to database changes using the Firebase client SDK in exactly the same way that you can when your app's code is running.
使用Firebase客户端SDK无法主动收听数据库更改,其方式与应用程序代码运行时完全相同。
If you want your app to receive information about changes to your database, you can instead use Firebase Cloud Messaging to send your app a notification with a small payload that contains information about the change. When your app receives the notification, it can then make a decision about what to do. There are some limitations with web support, so be sure to read about that.
如果您希望应用程序接收有关数据库更改的信息,则可以使用Firebase Cloud Messaging向应用程序发送包含有关更改信息的小负载的通知。当您的应用收到通知后,它就可以决定要做什么。 Web支持存在一些限制,因此请务必阅读相关内容。
Also look into Cloud Functions for Firebase to make it easier to write some server side code that can trigger in response to a database change and send a notification when those changes happen.
另请参阅Firebase的Cloud Functions,以便更轻松地编写一些服务器端代码,这些代码可以响应数据库更改而触发,并在发生这些更改时发送通知。
#1
0
It's not possible to actively listen to database changes using the Firebase client SDK in exactly the same way that you can when your app's code is running.
使用Firebase客户端SDK无法主动收听数据库更改,其方式与应用程序代码运行时完全相同。
If you want your app to receive information about changes to your database, you can instead use Firebase Cloud Messaging to send your app a notification with a small payload that contains information about the change. When your app receives the notification, it can then make a decision about what to do. There are some limitations with web support, so be sure to read about that.
如果您希望应用程序接收有关数据库更改的信息,则可以使用Firebase Cloud Messaging向应用程序发送包含有关更改信息的小负载的通知。当您的应用收到通知后,它就可以决定要做什么。 Web支持存在一些限制,因此请务必阅读相关内容。
Also look into Cloud Functions for Firebase to make it easier to write some server side code that can trigger in response to a database change and send a notification when those changes happen.
另请参阅Firebase的Cloud Functions,以便更轻松地编写一些服务器端代码,这些代码可以响应数据库更改而触发,并在发生这些更改时发送通知。