我必须为每组设备发送不同的消息。要不按消息发送消息,我想使用批处理选项。团体可以吗? (send batch messages doc)
示例:
const messages = [];
messages.push({
notification: { title: 'notf. Group 01', body: '...'}, // Message for group 01
token: notification_key, // Group key 01
});
messages.push({
notification: { title: 'notf. Group 02', body: '...'}, // Message for group 02
token: notification_key, // Group key 02
});
.
.
.
admin.messaging().sendAll(messages)
.then((response) => {
console.log(response.successCount + ' messages were sent successfully');
});
答案 0 :(得分:0)
根据documentation设备组消息传递是通过旧版XMPP或HTTP协议或基于旧版协议的Node.js的Firebase Admin SDK支持的。
据我了解,为了send a batch of messages,必须指定主题或指定目标主题的条件,然后将整个messages[]
数组作为参数传递给sendAll()方法。请注意,message type aliases中不包含通知键。
为了将消息发送到device group,通知键作为参数传递给sendToDeviceGroup()方法。再次查看用于发送成批消息的sendAll()方法,它没有参数以通知键作为输入。
希望以上内容对您有所帮助。