如何一次发送所有用户的Firebase通知? [英] How to send firebase notification for all user at a time?
问题描述
我有一个应用程序,可以一次向多个用户(不是所有用户)发送通知. 那么如何使用Firebase推送通知来做到这一点?
I have an application which sends notification for multiple users at a time(not all user). So how to do this using Firebase Push Notification?
推荐答案
您可以使用主题消息
基于发布/订阅模型,FCM主题消息传递使您可以向选择加入特定主题的多个设备发送消息.
Based on the publish/subscribe model, FCM topic messaging allows you to send a message to multiple devices that have opted in to a particular topic.
主题消息支持每个应用程序无限的主题和订阅.
Topic messaging supports unlimited topics and subscriptions for each app.
要订阅主题,客户端应用程序使用FCM主题名称调用Firebase Cloud Messaging subscriptionToTopic():
To subscribe to a topic, the client app calls Firebase Cloud Messaging subscribeToTopic() with the FCM topic name:
FirebaseMessaging.getInstance().subscribeToTopic("news");
要发送有关主题的通知:
To send a notification on topic :
https://fcm.googleapis.com/fcm/send
Content-Type:application/json
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA
{
"to": "/topics/news",
"data": {
"message": "This is a Firebase Cloud Messaging Topic Message!",
}
}
在此处了解更多信息: https://firebase.google. com/docs/cloud-messaging/android/topic-messaging
Read more at here : https://firebase.google.com/docs/cloud-messaging/android/topic-messaging
这篇关于如何一次发送所有用户的Firebase通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!