Firebase云functionhttp触发响应函数循环

我写了一些代码发送一个通知给我的所有注册到一个事件的用户,我使用http触发器,将在事件启动时被调用,我不能发送通知到设备组,因为事件可能不同,即使开始时间是一样的。

我的firebase节点看起来像这样:

registration |-- userid1 | |-- registration1 | | |-- FirebaseToken | | |-- EventName | |-- registration2 | |-- FirebaseToken | |-- EventName |-- userid2 

这是我的脚本:

 exports.sendNotification = functions.https.onRequest((request, result) => { admin.database().ref('/registration').once('value').then(snapshot => { snapshot.forEach(childSnapshot => { let list = childSnapshot.val() for (let key in list) { let p = list[key]; let token = p.FirebaseToken; console.log("Device token:", token); if (token != null && token != "") { let payload = { notification: { title: `The ${p.EventName}`, body: `The ${p.EventName} will be started soon.`, sound: "default" } }; // Set the message as high priority and have it expire after 1 hours. let options = { priority: "high", timeToLive: 60 * 60 }; admin.messaging().sendToDevice(token, payload, options) .then(response => { console.log("Successfully sent message:", response); }) .catch(error => { console.log("Error sending message:", error); }); } }; }); result.status(200).send("ok"); }); }); 

与此脚本,我设法发送通知给用户,但我得到了这样的日志Function execution took 1389 ms, finished with status code: 304

有没有更正或build议这样做。