如何使用Firebase云消息传递向所有设备发送通知 [英] How to send notifications to all devices using Firebase Cloud Messaging

查看:194
本文介绍了如何使用Firebase云消息传递向所有设备发送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Firebase文档中,它始终有一个to字段,其中包含设备/令牌ID ...但是,如何才能将其发送到所有设备。我该用什么替换字段,或者在那里放什么值。我完全删除它,但它回来了一个错误的要求。任何想法?
$ b

  {
to:bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1 ...,
数据:{
Nick:Mario,
body:非常棒!,
Room:PortugalVSDenmark
},
}


解决方案

您无法发送到所有设备。

使用 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).

这篇关于如何使用Firebase云消息传递向所有设备发送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆