Apple 推送通知:发送大量消息
我正在使用 PHP 连接到 apns 以向多个设备发送一些通知,尽管问题更具概念性,因此不必特定于 PHP。我将同时向大约 7000 台设备(并且还在不断增加)发送信息。我的进程每天运行一次并向所有设备广播,因此我不会经常重新打开连接。
open connection to apple
loop over device tokens
create payload aggregating all devices
end loop
write to socket ONCE with whole payload for 7000 devices
close connection
我可以像上面的伪代码那样做吗?
I am using PHP to connect to apns 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.
open connection to apple
loop over device tokens
create payload aggregating all devices
end loop
write to socket ONCE with whole payload for 7000 devices
close connection
Can I do like above pseudo-code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是正确的方法,但您需要检查 APN 反馈并删除“陈旧”设备。苹果会给你一份他们认为不再有效的代币列表。您应该修剪您的数据库,并且不再发送到这些令牌。
That is a correct approach but you need to check for APN Feedback and remove the "stale" devices. Apple will give you a list of tokens that they think are no longer valid. You should prune your database and never send to those tokens again.
这里的正确方法是,
由于每次写入都被视为特定于设备的消息,因此您一次可以写入一条消息。但您可以打开一次连接并写入尽可能多的内容。
Correct Approach here is,
As each write is considered as a message specific to device, you can write one message at a time. But you can open a connection once and write as many you can.