一次将通知推送到多个设备
Push Notification to multiple devices at once
我正在寻找一些意见,以解决我必须同时向多个设备发送推送通知的情况。通知将为其发送到的每个设备保留相同的消息。我查看了 AWS SNS,但我无法找到关于将多个设备订阅一个主题的想法的任何信息,或者这是否可能?如果不是,该问题的另一种解决方案是遍历 n 个设备令牌,这可能不是最有效的方法。
如果您有任何其他建议,将不胜感激!
提前致谢。
Firebase 云消息传递 提供您正在寻找的功能
以 Topic Messaging
的名义
https://firebase.google.com/docs/cloud-messaging/android/topic-messaging
在您的应用中,您可以订阅 topic
:
Android: FirebaseMessaging.getInstance().subscribeToTopic("news");
iOS: [[FIRMessaging messaging] subscribeToTopic:@"/topics/news"];
然后您的服务器可以向所有设备发送消息:
https://fcm.googleapis.com/fcm/send
Content-Type:application/json
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA
{
"to": "/topics/foo-bar",
"data": {
"message": "This is a Firebase Cloud Messaging Topic Message!",
}
}
我正在寻找一些意见,以解决我必须同时向多个设备发送推送通知的情况。通知将为其发送到的每个设备保留相同的消息。我查看了 AWS SNS,但我无法找到关于将多个设备订阅一个主题的想法的任何信息,或者这是否可能?如果不是,该问题的另一种解决方案是遍历 n 个设备令牌,这可能不是最有效的方法。
如果您有任何其他建议,将不胜感激!
提前致谢。
Firebase 云消息传递 提供您正在寻找的功能
以 Topic Messaging
https://firebase.google.com/docs/cloud-messaging/android/topic-messaging
在您的应用中,您可以订阅 topic
:
Android: FirebaseMessaging.getInstance().subscribeToTopic("news");
iOS: [[FIRMessaging messaging] subscribeToTopic:@"/topics/news"];
然后您的服务器可以向所有设备发送消息:
https://fcm.googleapis.com/fcm/send
Content-Type:application/json
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA
{
"to": "/topics/foo-bar",
"data": {
"message": "This is a Firebase Cloud Messaging Topic Message!",
}
}