Apple 推送通知:发送大量消息
我正在使用 PHP 连接到 apn 来向多个设备发送一些通知,尽管这个问题更具概念性,因此不必特定于 PHP。
我将同时向大约 7000 台设备(并且还在不断增加)发送信息。 我的进程每天运行一次并向所有设备广播,因此我不会经常重新打开连接。
目前,我可以轻松地一次发送到 2 台设备,并且消息将成功发送。 然而,当我尝试发送到全部 7000 台设备时,消息似乎无法发送。
我的代码的伪逻辑是:
open connection to apple
loop over device-tokens
write to socket connection per device
end loop
close connection to apple.
我在某个地方看到我应该只执行一次写入,并构造一个巨大的主体,换句话说,伪代码看起来像:
loop over device tokens
create payload aggregating all devices
end loop
open connection to apple
write to socket ONCE with whole payload for 7000 devices
close connection
很难测试,因为我显然不能发送垃圾邮件我的 7000 个生产用户带有测试消息。 还有其他人遇到过类似的问题吗?
谢谢
I am using PHP to connect to apn
s to send some notifications to multiple devices, although the question is more conceptual so it doesn't have to be specific to PHP.
I will be sending to about 7000 devices (and growing) all at the same time.
My process runs ONCE per day and broadcasts to all devices, so I am not constantly re-opening a connection.
Currently I can easily send to 2 devices at a time and the messages will successfully deliver.
However when I attempt to send to the full 7000 devices, the messages do not seem to deliver.
The pseudo-logic to my code is:
open connection to apple
loop over device-tokens
write to socket connection per device
end loop
close connection to apple.
I have seen somewhere that I should only perform a SINGLE write, and construct one huge body, in other words the pseudo-code would look like:
loop over device tokens
create payload aggregating all devices
end loop
open connection to apple
write to socket ONCE with whole payload for 7000 devices
close connection
It's difficult to test as I obviously can't spam my 7000 production users with test messages.
Has anybody else had a similar problem?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我听说苹果确实关心您与其服务器建立的连接数量,但我从未听说过任何写入限制。另外,我不确定您会在这里收到什么样的回复,但可能值得一试,看看会发生什么。也许可以尝试沙箱推送通知服务器,仅使用生产设备的设备令牌。这些手机不应接收发送到沙箱服务器的任何推送通知,如果沙箱报告“已成功发送”,那么这将是一种无忧的测试方式。
I've read that apple does care about the number of connections you make to their servers but I've never heard about any write limits. Also, I'm not sure about what kind of response you'd receive here, but it might be worth a try to see what happens. Maybe experiment with the sandbox push notification server, only using the device tokens of the production devices. Those phones should not receive any push notifications sent to the sandbox server and if the sandbox reports "delivered successfully", that would be a worry-free way to test.
我明白你想要什么,相反,我确实遇到了同样的问题,对我有用的是逆向工程。
我只是查看了库并检查了验证 deviceToken 的函数。因此,在创建虚拟设备令牌时,我只是确保生成的令牌根据库是有效的。
以下代码将让您生成有效设备令牌,现在由您决定使用此函数生成多少百万个令牌。
Apple deviceToken 有 64 个字符,因此您需要对其进行 64 次迭代。
I see what you want and rather, i did face the same problem, what worked for me was the reverse engineering.
I just looked into the library and checked for the function which validates the deviceToken. So while creation of dummy device token i just made sure that the generated token is valid as per the library.
The following code will let you generate valid device Tokens, now its on you to how many millions of tokens to generate using this function.
The apple deviceToken is of 64 character so you will need to iterate on it for 64 times.