FCM 发送一批消息(设备组)
FCM Send a batch of messages (device groups)
我必须为每组设备发送不同的消息。为了不通过消息发送消息,我想使用批处理选项。团体可以吗? (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');
});
根据 documentation 设备组消息通过旧版 XMPP 或 HTTP 协议或基于旧版协议的 Node.js 的 Firebase Admin SDK 得到支持。
据我了解,为了send a batch of messages the registration token, topic or a condition that specifies the target topics must be specified and then send the whole messages[]
array by passing it as an argument to the sendAll() method. Note that notification keys are not included to the message type aliases。
为了将消息发送到用于发送批量消息的 device group, the notification key is passed as an argument to the sendToDeviceGroup() method. Looking again at the sendAll() 方法,它没有将通知键作为输入的参数。
希望以上内容对您有所帮助。
我必须为每组设备发送不同的消息。为了不通过消息发送消息,我想使用批处理选项。团体可以吗? (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');
});
根据 documentation 设备组消息通过旧版 XMPP 或 HTTP 协议或基于旧版协议的 Node.js 的 Firebase Admin SDK 得到支持。
据我了解,为了send a batch of messages the registration token, topic or a condition that specifies the target topics must be specified and then send the whole messages[]
array by passing it as an argument to the sendAll() method. Note that notification keys are not included to the message type aliases。
为了将消息发送到用于发送批量消息的 device group, the notification key is passed as an argument to the sendToDeviceGroup() method. Looking again at the sendAll() 方法,它没有将通知键作为输入的参数。
希望以上内容对您有所帮助。