4. Push technology, or server push, describes a style of Internet-
based communication where the request for a given
transaction is initiated by the publisher or central server.
› Harder to implement
› Less battery consumption
› Constant connection
5. Push me your news!
Any news?
No!
Any news?
No!
Any news?
No! New News!
content!
Any news?
Yes! (News)
› Transfer
content as soon as available
› Save device battery
› Reduce data traffic for user
6. › HaIt
allows third-party application servers to
send lightweight messages to their Android
applications
› C2DM makes no guarantees about delivery or
the order of messages
› An
application on an Android device doesn’t
need to be running to receive messages
7. › It
does not provide any built-in user interface or
other handling for message data
› It
requires devices running Android 2.2 or higher
that also have the Market application installed
› It
uses an existing connection for Google
services
8. 1. Register device for Push 3. Device receives message
2. App server send message 4. Unregister device
9. › Requesting a Registration ID
C2DMessaging.register(this, "sender@gmail.com");
10. › Receiving the Registration ID
public class C2DMReceiver extends C2DMBaseReceiver {
public C2DMReceiver() {
super("sender@gmail.com");
}
@Override
public void onRegistered(Context context, String registrationId) {
// TODO send registration ID to the app server
}
...
}
11. › Receiving Messages
public class C2DMReceiver extends C2DMBaseReceiver {
...
@Override
protected void onMessage(Context context, Intent intent) {
String payload = intent.getStringExtra("payload");
// TODO handle the message
}
}