用于推送通知的Firebase云功能

用于推送通知的Firebase云功能,firebase,push-notification,firebase-cloud-messaging,google-cloud-functions,Firebase,Push Notification,Firebase Cloud Messaging,Google Cloud Functions,我可以发送推送通知,而无需请求交付\接收。在添加delivery\u receipt\u requested字段时,我发现了一个错误。 每当从Firebase云功能向设备发送通知时,我想更新数据库中的一个字段 发送消息时出错:{错误:接收到无效的JSON负载。未知 “消息”处的名称“已请求传递\接收”:找不到字段。 在FirebaseMessagingError.Error(本机) 在FirebaseMessagingError.FirebaseError[作为构造函数](/user\u cod

我可以发送推送通知,而无需请求
交付\接收
。在添加
delivery\u receipt\u requested
字段时,我发现了一个错误。 每当从Firebase云功能向设备发送通知时,我想更新数据库中的一个字段

发送消息时出错:{错误:接收到无效的JSON负载。未知 “消息”处的名称“已请求传递\接收”:找不到字段。 在FirebaseMessagingError.Error(本机) 在FirebaseMessagingError.FirebaseError[作为构造函数](/user\u code/node\u modules/firebase admin/lib/utils/error.js:39:28) 在FirebaseMessagingerError.PrefixedFreebaseError[作为构造函数](/user\u code/node\u modules/firebase admin/lib/utils/error.js:85:28) 在新的FirebaseMessagingError(/user\u code/node\u modules/firebase admin/lib/utils/error.js:241:16) 位于Function.FirebaseMessagingError.fromServerError(/user\u code/node\u modules/firebase admin/lib/utils/error.js:271:16) at/user\u code/node\u modules/firebase admin/lib/messaging/messaging api request.js:149:50 在进程中。_tickDomainCallback(internal/process/next_tick.js:135:7)errorInfo:{code: “消息传递/参数无效”, 消息:'接收到无效的JSON有效负载。在'message\'处的未知名称“delivery\u receive\u requested”:找不到字段。},
codePrefix:“消息传递”}

我的有效载荷结构

  var payload = {
                delivery_receipt_requested:true,
                  notification: {
                    title: user,
                    body: snapshot2.val()
                  },
                  android: {
                    notification: {
                    sound: "default"
                    }
                  },
                  token: userToken
                };

 admin.messaging().send(payload)
                .then((response) => {
                    // Response is a message ID string.
                    console.log('Successfully sent message:', response);
                    return 1;
                })
                .catch((error) => {
                    console.log('Error sending message:', error);
                    return 0;
                });
            return snapshot2.val()
            }).catch(error => {
                console.log("Error" + userToken2)
            });

我看不到中定义了请求的
交付\接收
。“你在哪里找到的?”“是我的错。”。没有这样的领域。我看错地方了。它从应用服务器使用,以便FCM可以确认交付。我如何确认Firebase云功能发送通知?当
send()
返回的
Promise
成功解析(
send())后(…)
),服务器已接收并接受您的消息。我们如何验证设备何时收到消息?HTTP API不支持这一点。