且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用Firebase云功能将设备发送到设备通知?

更新时间:2023-09-08 14:24:22

要能够使用Firebase向某些用户发送通知,您可以编写一个JavaScript函数,该函数将侦听某些触发数据库的事件.

To be able to send notifications to certain group of users with Firebase, you can write a JavaScript function that will listen for some events that triggers your database.

触发此事件后,您可以执行操作,在这种情况下,您将需要编写JavaScript(或TypeScript)函数,该函数可以找到设备令牌以发送通知和通知有效负载.该示例非常清楚如何进行操作,并且是Firebase函数存储库中的函数示例集合的一部分.

When this events are triggered you can perform an operation, in this case, you will need to write a JavaScript (or TypeScript) function that can find the device token to send the notification and a notification payload. This example is very clear on how to do it, and it's part of a collection of function samples on the Firebase functions repo.

https://github.com/firebase/functions -samples/tree/Node-8/fcm-notifications