【问题标题】:Send FCM notification to multiple tokens using Plokko Firebase使用 Plokko Firebase 向多个令牌发送 FCM 通知
【发布时间】:2021-06-06 08:04:43
【问题描述】:
我正在使用 Plokko FCM v1 库:https://github.com/plokko/php-fcm-v1
到目前为止,我正在使用一个循环发送到多个令牌,并且它变得太慢了,因为每个循环都在等待发送通知,如何像我们在旧版中那样一次发送到多个令牌HTTP 代码。
我尝试将其设为数组,两次都是逗号分隔的值
注册令牌不是有效的 FCM 注册令牌
任何帮助都会得到帮助
谢谢
【问题讨论】:
标签:
php
firebase
firebase-cloud-messaging
【解决方案1】:
您必须使用 registration_ids 而不是 to 来创建对象并制作设备令牌数组并将其分配给 registration_ids,如下所示
const id = deviceIds;
const Title = "Title";
const message = "This is testing notification";
const messaged = {
registration_ids: id, //// multiple devices
// to: id, //// use for single device
collapse_key: 'appName',
notification: {
title:Title,
body: message
}
};
await fcm.send(messaged, function(err, response){
if (err) {
console.log(err)
// result(null,{success:false,message:"Some Error", data:err});
} else {
console.log(response)
}
});