Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,35 @@ To send a notification, you can do it in two steps:

C2DMService service =
C2DM.newService()
.withAuthToken(("serviceAuthenticationToken")
.withAuthToken("serviceAuthenticationToken")
.build();

2. Create and send the message

C2DMNotification notification = C2DM.newNotification()
.collapseKey("daily_message").delayWhileIdle(true)
.build();
.collapseKey("daily_message")
.data("payload", "Here be dragons (or another message)")
.delayWhileIdle(true)
.build();
String registrationId = "deviceRegistrationID";
service.push(registrationId, notification);
(Read http://stackoverflow.com/questions/4164921/who-provides-auth-token-to-use-with-c2dm in order to get the serviceAuthenticationToken)


That's it!

On the device, you will be able to recieve the message by doing this:

@Override
protected void onMessage(Context context, Intent intent) {
//Extract the payload from the message
Bundle extras = intent.getExtras();
if (extras != null) {
System.out.println(extras.get("payload")); //Will print to the logcat
// Do something with the data you recieved
}
}

Features In the Making
---------------------------
* Auto retries (exponential back-off feature)
Expand Down