实现这一目标的最简单方法是通过调用 remove() admin sdk提供的功能, 你可以得到参考 notification_id 通过这个事件,即 event.params.notification_id 然后在需要时将其删除 admin.database().ref('pass in the path').remove(); 你很高兴。
remove()
notification_id
event.params.notification_id
admin.database().ref('pass in the path').remove();
首先,使用 .onCreate 代替 .onWrite 。您只需在第一次写入时阅读每个孩子,这样可以避免不良副作用。请参阅文档 这里 有关可用触发器的更多信息。
.onCreate
.onWrite
event.data.ref() 保存事件发生的参考。你可以打电话 remove() 在删除它的引用上:
event.data.ref()
return event.data.ref().remove()