java - How to listen for added nodes in the firebase database
问题描述
I know how to read data from the firebase database, in my database structure, there is a child with various nodes written and pushed by users. How can I add a listener that will tell me whenever a new node has been added in the child and trigger a notification. Please note I already have a method for creating a notification. I don't want to know the contents of the child added, I just want to know whenever a new child is added. How would I go about this?
解决方案
对于此功能,您需要将 Firebase函数与数据库触发器一起使用
您可以在此处查看此功能的示例
基本上它是如何工作的
- 你写一个函数(打字稿/javascript)
- 您将该函数部署到 Firebase 函数中由于您在函数中使用了数据库触发器,因此只要在您正在侦听的节点内插入新项目,该函数就会触发
- 触发器是 onCreate()
- 您将制作一个通知负载,该负载将发送到您存储在子节点中的用户设备令牌
推荐阅读
- c++ - MPI & OpenMP:omp_get_max_threads 返回一半的真实线程容量
- javascript - 连续跟踪触摸屏
- c# - ReCaptcha 3 HTML Helper 在按钮中单击 ASP.NET MVC
- ios - iOS MapBox 适合相机到多个坐标 [纬度和经度] 或注释
- javascript - Javascript不将类添加到标签
- react-native - React Native - 从没有库的命令行切换 .env
- algorithm - 以最小成本断开无向加权图中的两个节点
- python - 由于 Python 中的破折号,我无法导入库
- blogs - 本地或 Netlify 上的 Hugo 站点未检测到我的内容文件夹
- python - 从延迟加载页面中提取href