Apple 推送通知:发送大量消息

发布于 2024-11-07 09:06:25 字数 360 浏览 4 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦毁影碎の 2024-11-14 09:06:25

这是正确的方法,但您需要检查 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.

烟燃烟灭 2024-11-14 09:06:25

这里的正确方法是,

you can open the connection.
perform as many writes as you like.
just make sure you check the connection status after each write
close the connection.

由于每次写入都被视为特定于设备的消息,因此您一次可以写入一条消息。但您可以打开一次连接并写入尽可能多的内容。

Correct Approach here is,

you can open the connection.
perform as many writes as you like.
just make sure you check the connection status after each write
close the connection.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文