本文介绍了Firebase 云消息传递 (FCM) - HTTP V1 API 还是旧版 HTTP API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的目标是从我们的后端向设备组发送通知,并且只有服务器端才可能知道哪个设备应该接收通知.

Our goal is sending notifications to groups of devices from our backend, and only from server side is possible to know which device should receive the notification.

我们已经对 AppCenter 进行了一些尝试,因为我们主要使用 Xamarin iOS/Android/Forms,但现在我们怀疑直接使用 Firebase API 可能更好,因为它更广泛、更强大.

We've done some attempts with AppCenter because we mostly work with Xamarin iOS/Android/Forms, but now we have the doubt that it's probably better to use directly Firebase API because wider and more powerful.

我发现使用新版本的 API (HTTP V1) 无法向令牌列表发送通知,使用 registration_ids 参数(https://firebase.google.com/docs/cloud-messaging/send-message).

I see that with new version of API (HTTP V1) is not possible to send a notification to a list of tokens, feature that was available in legacy API using registration_ids parameter (https://firebase.google.com/docs/cloud-messaging/send-message).

设备组名称(仅限旧协议)

我不能使用主题,因为何时发送通信是服务器的责任,为通知准备邮件列表".

I cannot use topics because when it's time to send the communication is a server's responsibility to prepare the "mailing list" for notifications.

我想使用设备组消息传递 (https://firebase.google.com/docs/cloud-messaging/android/device-group) 但这些是旧 API 的一部分,我不确定这是否有意义/是否可以将它们与新版本的API.

I was thinking to use device group messaging (https://firebase.google.com/docs/cloud-messaging/android/device-group) but these are part of the legacy api, and I'm not sure if it makes sense/it's possible to use them with new version of API.

是否可以选择将一批 100-200-500 条推送通知发送给一个令牌?理论上,可以发送的通知没有限制,但我担心发送过多的通知可能会被禁止.

Is an option to send a batch of 100-200-500 push notifications each one to only one token? In theory there isn't a limit to notifications which is possible to send, but I'm worried that sending too many of them I could risk to be banned.

使用旧 API 是否更好?此外,AppCenter (Microsoft) 使用旧 API,这很明显,因为设置的工作方式以及从 AppCenter 的控制台可以向令牌列表发送通知,Firebase 的控制台上不可用的功能.

Is it better to use legacy API? Also AppCenter (Microsoft) uses legacy API, it's evident because of how the setup works and because from AppCenter's console it's possible to send notifications to a list of tokens, feature unavailable on Firebase's console.

另一个人刚刚问了类似的问题,但答案是使用主题(如何一次为所有用户发送 firebase 通知?).

Another person just asked something similar but the answer was to use topics (How to send firebase notification for all user at a time?).

推荐答案

从您在我的回答中的评论链接中获得这里.在这里重申我的回答,当使用 v1 向多个令牌发送消息时,现在建议的方法是使用主题消息传递,因为不支持 registration_ids.

Got here from the link in your comment in my answer here. And just to reiterate my response there, when sending messages to multiple tokens with v1, the suggested approach now is to use Topics Messaging, since registration_ids is not supported.

使用旧 API 是否更好?

v1 被描述为 更安全,跨平台、面向未来的向 FCM 客户端发送消息的方式.更安全,因为它使用 OAuth2 安全模型.

v1 was described as the more secure, cross platform, future proof way of sending messages to FCM clients. More secure since it uses OAuth2 security model.

但是,如果您的用例更适合使用旧版 API,那么我建议您继续使用它.

However, if your use-case is better with using the legacy API, then I suggest you go ahead with using it.

这篇关于Firebase 云消息传递 (FCM) - HTTP V1 API 还是旧版 HTTP API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 13:02