我们是否需要复杂的GCM / FCM发送策略? [英] Do we need complex sending strategies for GCM / FCM?

查看:167
本文介绍了我们是否需要复杂的GCM / FCM发送策略?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我正在开发支持多租户的SaaS,可为其用户群启用推送通知。
我正在考虑使用消息队列来存储所有推送,并使用单独的服务发送它们。该新服务需要从队列中读取并发送推送通知。

Currently I'm working on a SaaS with support for multiple tenants that can enable push notifications for their user-bases. I'm thinking of using a message queue to store all pushes and send them with a separate service. That new service would need to read from the queue and send the push notifications.

现在我的问题是:我是否需要提出复杂的发送策略?我知道使用GCM每个请求最多有1000个设备,因此需要考虑这一点。我也不能等待x推进,因为这可能会延迟先前发送的推送。我的下一个想法是创建一个全局数组,并通过从队列中推入来填充它。然后循环会每隔1秒取出一个数组并发送推送。这种方式推送肯定会发送,我不会超过1000设备限制。

My question now is: Do I need to come up with a complex sending strategy? I know that with GCM has a limit of 1000 devices per request, so this needs to be considered. I also can't wait for x pushes to fly in as this might delay a previous push from being sent. My next thought was to create a global array and fill it with pushes from the queue. A loop would then fetch that array every say 1 second and send pushes. This way pushes would get sent for sure and I wouldn't exceed the 1000 devices limit.

所以...虽然这可能工作,我不知道如果一个无限循环是最好的方式。我想知道GCM / FCM是否有请求限制?如果不是的话,我不需要首先将推动力集中起来,我就可以放弃这个循环。我可以简单地为从队列中取出的每个推送发出一个请求。

So ... although this might work I'm not sure if an infinite loop is the best way to go. I'm wondering if GCM / FCM even has a request limit? If not, I wouldn't need to aggregate the pushes in the first place and I could ditch the loop. I could simply fire a request for each push that gets pulled from the queue.

任何有关此主题的启示或改进我的原型算法都会很棒!

Any enlightenment on this topic or improvement of my prototypical algorithm would be great!

推荐答案


我需要想出一个复杂的发送策略吗?

不是。 GCM / FCM非常简单。只需将消息发送到GCM / FCM服务器,然后它将自行排队,然后(根据行为)尽快发送。

Not really. GCM/FCM is pretty simple enough. Just send the message towards the GCM/FCM server and it would queue it on it's own, then (as per it's behavior) send it as soon as possible.


我知道使用GCM每个请求最多可以有1000个设备,因此需要考虑这一点。

我认为您对每个请求限制的1000个设备感到困惑。 1000设备限制是指在使用 registration_ids 参数:

I think you're confusing the 1000 devices per request limit. The 1000 devices limit refers to the number of registration tokens you add in the list when using the registration_ids parameter:


此参数指定设备列表(注册令牌或ID)接收多播消息。它必须包含至少1注册令牌

这意味着您只能发送给1000设备在一个请求中具有相同的消息有效载荷(如果需要,您可以执行批量请求(1000 /每个请求)。)

This means you can only send to 1000 devices with the same message payload in a single request (you can then do a batch request (1000/each request) if you need to).


AFAIK,那里有一个请求限制没有这样的限制。沟环。每当您成功向GCM / FCM服务器发送消息时,它都会排队并保留该消息,直到消息可以发送为止。

AFAIK, there is no such limit. Ditch the loop. Whenever you successfully send a message towards the GCM/FCM server, it will enqueue and keep the message until such time that it is available to send.

这篇关于我们是否需要复杂的GCM / FCM发送策略?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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