开发者

Apple Push Notification Service - Many notifications to send

开发者 https://www.devze.com 2023-03-06 19:35 出处:网络
I am now trying to develop the part of my server which will handle sending notifications to APN (then to iphones).

I am now trying to develop the part of my server which will handle sending notifications to APN (then to iphones). In fact, it is a dedicated service running on my server. Every 15 minutes, this service looks in my MySQL database for notifications to send.

I have deal with all the certificate part, and I am trying to define the best strategy to implement that. Ì plan to use :

I have two questions regarding that :

  • Do you have advice regarding what I plan to do ?
  • As every 15 minutes I will send around 1 000 notifications (1x to 1 000 phones), is there a special way to hande this overload ?

Thanks for your help !

Kheraud


I'm not sure why you want to run this job every 15 minutes. Is that time interval significant to your app, or is it some arbitrary number? In the rest of my answer I'm assuming the latter.

You need to create a background process that keeps a permanent connection open to APNS. This is better than running your program from a cron job because setting up the SSL connection over and over is very expensive. (Although if you really want to stick to the 15 minute thing, I suppose running from a cron job is not so bad. Just don't open and close a connection for every notification you want to send out.)

Instead of sending 1000 notifications every 15 minutes, send 100 notifications every minute. Or rather, send a few notifications every second.

If you have a lot of notifications to send, you can open multiple connections to APNS for the same app (but no more than 15).

For extreme efficiency, you can bundle multiple notifications in each packet you send to APNS (for example using Nagle's algorithm).

0

精彩评论

暂无评论...
验证码 换一张
取 消