Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

I'm currently developing an App and as I implemented the C2DM feature it got me thinking how does this work?

Does it work via polling? Is there a hidden SMS? How are they pushing the Message on my device?

share|improve this question
    
Development questions are off-topic here. –  Matthew Read Jan 24 '12 at 14:41
1  
That's not a development question, the question is how Google does implement it. It's a background question - you're able to implement C2DM just fine without knowing how Google did it. –  schlingel Jan 24 '12 at 15:10
    
Fair enough, my mistake. AFAIK C2DM takes advantage of the Google Talk service, or used to, but I'm not familiar with the details. –  Matthew Read Jan 24 '12 at 15:24
add comment

2 Answers

Based on this document: And this is basically how other push notification services work as well...

  1. The application requests a token for the device
  2. C2DM responds with the registration token for the specific device
  3. The application sends the token to your server on the web.
  4. Your service can now communicate with C2DM (after authenticating), and using the registered device tokens, C2DM will send the messages to the devices.

On the C2DM side, the token is associated with a specific device. When you send a push notification through C2DM, the Google servers send that info to the device. C2DM libraries on the device "listen for them" and pass them on to the intents as needed.

share|improve this answer
    
How do the libraries "listen for them"? Is there a polling service running? Does the provider play a role? –  schlingel Jan 24 '12 at 15:57
1  
It's not polling, the point of push is so it doesn't have to poll for updates. its more of like a socket that is open for the data to come in, like a broadcast receiver. –  Ryan Conrad Jan 24 '12 at 16:29
2  
@schlingel Looks like you need to ask "How does push technology work?".. Its independent from this Android question.. –  Sachin Shekhar Jan 24 '12 at 16:35
    
I don't see why Google has to implement it the same way Apple did. I just want to know how this "email push type technology" works. I would bet money that Apple, Google and Blackberry have different solutions. –  schlingel Jan 25 '12 at 8:11
2  
Actually, apple implemented it the same way google did. Google has push notifications before Apple did. And for the record, Windows Phone basically works the same way too. There is really no other way to implement push, you need a way to "identify" the device, and the app registering for the notification gives sort of an "authentication token" for the app. –  Ryan Conrad Jan 25 '12 at 14:27
add comment

Android provides system-wide intents for such type of app triggering. For C2DM, there's a whole class of intents looks like com.google.android.c2dm.*. To use these intents, you'll need to add broadcast receivers in your app and register it with system.
To make it really work, you'll need remote push service too. Your software on server must be capable of messaging to Google's C2DM server using HTTP/HTTPS.
Now, whenever a push protocol based communication from C2DM server is established, Android system triggers app based on intents registered at the time of app installation...

Update:
More clearly, when your application push server pushes message to Google's C2DM server, Google checks token attached with message. Mind it, this token was generated by com.google.android.c2dm.intent.register if user had logged in with Google Account. So, using this token, Google comes to know exact delivery location. Then, Google makes use of Google Services Framework to push message in raw key-value pair format...

Polling or not?
No. It utilities same email push type technology in which connection between server & client is kept open. So, no need to run polling service..

share|improve this answer
2  
Yes, I'm aware of this but how does Google creates this intents on my device? –  schlingel Jan 24 '12 at 15:11
    
Still unable to understand you, but tried again with update.. See my update & argue again please.. –  Sachin Shekhar Jan 24 '12 at 16:37
    
I want to know how this "email push type technology" works. How often do they poll? In the end, they have to - or am I wrong here? –  schlingel Jan 25 '12 at 13:31
    
There's nothing to do with poll here. In polling situation, server is unaware of client. It's responsibility of client to check data stored on server. But, in push situation, it works like SMS delivery.. client just keeps it's connection with server open and it's responsibility of server to send data. Server do it again and again unless it receives delivery status.. So, we start getting old emails when we turn on our device... There's no need to poll here... –  Sachin Shekhar Jan 25 '12 at 14:57
    
How server sends something can be understood as point-to-point POST if you know HTTP 1.0 protocol RESTful API or form POST method offered by ASP.NET/ PHP.. –  Sachin Shekhar Jan 25 '12 at 15:02
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.