Apple Push Notification: Sending high volumes of m

2019-08-21 02:14发布

问题:

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?

回答1:

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.



回答2:

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.