向多个设备发送推送通知 FCM API V1

Sending push notifications to multiple devices FCM API V1

提问人:Vans 提问时间:11/16/2023 更新时间:11/17/2023 访问量:25

问:

您能否告诉我是否可以像在 Cloud Messaging API(旧版)中一样在 Firebase Cloud Messaging API (V1) 中使用 curl 向多个设备发送云消息?

{
   "message":{
      "token":"",
      "notification":{
        "body":"This is an FCM notification message!",
        "title":"FCM Message"
      }
   }
}
卷曲 发布 firebase-cloud-messaging

评论


答:

0赞 Predrag Maksimovic 11/17/2023 #1

首先,您需要在站点内应用程序注册主题,例如

FirebaseMessaging.getInstance().subscribeToTopic("theme_name");

然后:

{
  "to": "/topics/theme_name",
  "notification": {
    "title": "title",
    "body": "Body"
  }
}

评论

0赞 Vans 11/17/2023
提示,那么推送通知会发送给哪些用户?
0赞 Predrag Maksimovic 11/20/2023
订阅theme_name的用户
0赞 Vans 11/20/2023
用户如何注册此线程?
0赞 Vans 11/20/2023
是否可以使用 http 请求 (curl) 向主题添加令牌?