更新时间:2023-02-26 21:13:21
您无法发送到所有设备。
使用 Firebase Cloud Messaging API 。或者,您可以发送到用户群,特定设备或使用 Firebase通知控制台。
通过Firebase通知,您可以获得最近的,因为有一个默认的用户分段,其中包含安装了特定应用的所有设备。所以,如果你有一个Android和一个iOS应用程序,这将是两个通知。但是没有给这样的观众发送程序化的方式(还)。
On the Firebase doc, it always has a "to" field with a device/token id... but how can I get it to send the notification to all devices. What do I replace the to field with, or what value do I put in there. I'd removed it altogether but it comes back with an error asking for it. Any ideas?
{
"to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
"data" : {
"Nick" : "Mario",
"body" : "great match!",
"Room" : "PortugalVSDenmark"
},
}
You cannot send to "all devices".
Instead you can target a specific device, a group of devices or a topic when using the Firebase Cloud Messaging API. Alternatively you can send to a user segment, a specific device, or a topic when using the Firebase Notifications console.
With Firebase Notifications you can get closest, since there is a default user segment that includes all devices that have a specific app installed. So if you have an Android and an iOS app, that would be two notifications. But there's no programmatic way to send to such an audience (yet).