Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js FCM发送推送至设备组返回';消息/无效收件人';_Node.js_Firebase_Firebase Cloud Messaging - Fatal编程技术网

Node.js FCM发送推送至设备组返回';消息/无效收件人';

Node.js FCM发送推送至设备组返回';消息/无效收件人';,node.js,firebase,firebase-cloud-messaging,Node.js,Firebase,Firebase Cloud Messaging,您好,我正在尝试使用Firebase云功能通过FCM向如下设备组发送推送通知: // Send a message to the device group corresponding to the provided // notification key. admin.messaging().sendToDeviceGroup(notification_key, payload) .then(function(response) { // See the MessagingDeviceGroup

您好,我正在尝试使用
Firebase云功能
通过
FCM
向如下设备组发送推送通知:

// Send a message to the device group corresponding to the provided
// notification key.
admin.messaging().sendToDeviceGroup(notification_key, payload)
.then(function(response) {
// See the MessagingDeviceGroupResponse reference documentation for
// the contents of response.
    console.log("Successfully sent message:", response);
})
.catch(function(error) {
   console.log("Error sending message:", error);
   });
}
控制台返回我:

{ code: 'messaging/invalid-recipient',
 message: 'Notification key provided to sendToDeviceGroup() is invalid.' } }
我使用的
notification_key
是:
const notification_key=“APA91bG09Lqs…rb48dE5hs”

并且是我创建设备组时在响应中返回的
通知键

我注意到您有
const notificationKey=“APA91bG09Lqs…rb48dE5hs”但随后有
发送到设备组(通知键,有效负载)
。它不应该是
sendToDeviceGroup(notificationKey,payload)
?是的……就像那样。。。我写问题的时候不好。。。将编辑以清除错误以及。。。我传递的是创建设备组时收到的值。当我创建一个组时,我收到了一个形式为“APA91bG09Lqs…rb48dE5hs”
->的响应,我最终将其与
通知密钥名称一起存储在数据库中作为参考。好的。我对sendToDeviceGroup了解不多,但我真的应该像使用Node.js服务器一样使用它。我用“旧”的方式发送消息,方法如下-。但是你的例子没有理由不起作用。我明白了。。。按照我看到的旧方法,您还需要
注册密钥
。。。对吧。。。我在想,也许通过
sendToDeviceGroup
我也需要这个。。。所以也许这就是为什么它不起作用。。。