My iPhone is able to receive push notifications, iMessages, etc. in real time. Does this mean that when iPhone connects to the internet, it establishes and maintains a continuous connection to Apple’s servers? Or do the servers make a connection to the device each time they have new data to push? And if so, how can they always know where to reach your device considering that the IP on a mobile device could change quite easily across WiFi networks, cell towers, etc.
Does iOS maintain a constant connection to Apple’s servers?
It is not a constant connection. For instance, when app launches, it connects to Apple and then get notifications.
These 2 posts will give some details:
https://stackoverflow.com/questions/13897575/apns-apple-push-notification-service-reliability https://stackoverflow.com/questions/25830597/how-to-know-push-notification-delivery-status/25830955#25830955