Apple plans to change its Push Notification Service next year and has warned developers that now is the time to migrate to the latest version. The message recently appeared on Apple's developer web site. The current build of the service will no longer support the legacy binary protocol starting in November 2020. Here's what developers need to know.
"If you send push notifications with the legacy binary protocol, we recommend updating to the HTTP/2-based APNs provider API as soon as possible," said Apple. "You’ll be able to take advantage of great modern features, such as authentication with a JSON Web Token, improved error messaging, and per-notification feedback."
According to Apple, when apps intend to send a notification to an iPhone owner, the provider has to build a POST request and then deliver it to the Apple Push Notification service. A handful of items must be checked off the list before Apple will act on the request.
For example, the request will need the JSON payload the app wants to send, the device token for the end user's iPhone or iPad, a request-header field detailing how the notification should be delivered, as well as the provider's current authentication token for token-based authorizations.
Transiting the Apple Push Notification service follows this chain of operations. When the server POST request arrives, the Apple Push Notification service validates the request with either the server certificate or the authentication token. Once validated, the service uses the device token to identify the user's specific device. Only after this token is confirmed will the Apple Push Notification service attempt to send the JSON payload to the phone.
Apple has a detailed overview of each step in this process available here. Some takeaways. Use HTTP/2 and TLS 1.2 or later because Apple Push Notification service ignores HTTP/2 PRIORITY frames. There are six valid values for the APNs-type-header field: alert, background, VoIP, complication, fileprovider, and MDM. Other headers are optional, but this table needs to be filled out. Examples of properly built requests are available on the developer web site.