source:http://stackoverflow.com/questions/11508613/how-does-push-notification-technology-work-on-android
From what I've heard during an Android developers conference in Israel:
There is simply a TCP socket waiting in accept mode on a cloud Google server. The TCP connection had been initiated by the Goggle Play application. That's why Google Play must be installed on the device for makingGoogle Cloud Messaging (GCM) (formerly Android Cloud to Device Messaging Service - C2DM) work.
When this TCP client socket receives some message, the message contains information such as the package name of the application it should be addressed to, and of course - the data itself. This data is parsed and packed into an intent that is broadcast and eventually received by the application.
The TCP socket stays open even when the device's radio state turns into "idle" mode. Applications don't have to be running to receive the intents.
More information at
Q: But I think it works on emulator as well. The thing that come into my mind is that the device keep server updated with its current path (IP). When google server needs to send notification, it takes its current path and forward message to that path. Am I right to some extent?
A: When the device's IP changed from some reason, the device disconnects from server. when it happens - new connection astemblish instead, based on the device new IP.
댓글
댓글 쓰기