-
Notifications
You must be signed in to change notification settings - Fork 373
Why open multiple connections to the APNs?
The APNs binary interface is asynchronous, which in a nutshell means that when you write to the APNs it does not respond with an acknowledgement for a valid notification. Delivery errors to the device are reported back via a separate Feedback Service.
The catch is that the APNs does respond after a write if the notification payload is invalid. A payload is invalid if the notification binary payload itself is malformed, not that it could not be delivered to the device. For any library wanting to record these invalid payload errors - like rpush does - it must wait for a response after every notification is sent. Because the APNs will only respond for an invalid notification, the only way to avoid waiting for infinity when a valid notification is sent is to use a timeout.
With only a single connection and an error check timeout of half a second and 10,000 notifications to deliver... well, you're going to be waiting for a long time. With multiple connections, we can improve that by sending multiple notifications concurrently.
Apple really ruined what could have been a very easy to use protocol :(