How long do Apple retain notifications to be pushed to iOS devices until they expire?
It depends on the service that sent the notification in the first place. The service (i.e. the backend system that supports an app such as Facebook or any other app) sends their notifications to Apple's push notification service over a HTTP/2-based API. In that API it sets a parameter known as &quot;apns-expiration&quot;, which determines how long time Apple's push notification service will queue the notification to be delivered when the device is online again.
The &quot;apns-expiration&quot; parameter can be set to 0, which means that it won't be queued at all.
If set to a higher number than 0 that is the date and time (represented as the number of seconds since midnight on the 1st of January 1970 in UTC), the message will be removed from queued.
Finally, the service can choose not to send the parameter at all, or send it as -1 (negative). This means it should be queued for as long as possible.
The maximium queue time is not infinite, but is chosen by Apple - and seemingly not documented anywhere. However, PC World described in 2009 that the maximum at that time was 28 days:
https://www.pcworld.com/article/167652/the_limits_of_apples_push_notification_for_the_iphone.html