问题
I implemented EasyAPNS in my app and server and currently have a database with 2000+ registered devices.
Today I tried to send notifications to all of these devices and the script timed out. I checked the code (should've done it earlier, I know) and I discovered it opens a connection for each message.
Basically this thing will never work and will get my IP banned, right? How's it even possible that this problem is not mentioned anywhere in the Google group? Apparently nobody tried this library with a lot of notifications -- can this be real? Or am I missing something?
回答1:
I ended up rewriting a lot of the code that sends the messages to the APNS. Basically instead of looping through each message opening and closing the connection every time, just fetch N messages (probably the limit is 100) from the database every minute and send them in one shot. Do this until the messages table is empty (I used a cron job for this). I also had to do some more work because I needed multiple application support.
I'm not sure what the EasyAPNS guys were thinking when they wrote that library. Honestly, it didn't help at all -- it would have been better if I had written the APNS code from scratch on my own. Should anybody need help in modifying the library, just comment this post.
回答2:
APNS gets your IP blocked. I agree with pt2ph8.
One quick question, though to pt2ph8. Is it possible to create a library that will handle the APNS for multiple apps?
来源:https://stackoverflow.com/questions/5625480/easyapns-has-anybody-tried-it-with-large-amounts-of-notifications