5 surprises about programming C2DM

I have been writing code to use C2DM, Android Cloud to Device Messaging (i.e. notifications). Here are 5 surprises that I spent a lot of time figuring out.

1) There are two popular pages (here and here) about how to program C2DM. However, developers typically don't use these code examples. Most people copy several files from the chrometophone app as outlined in this tutorial. I would guess at some point the chrometophone code will be added to the Android API.

2) The project is in beta, so you have to register and be approved. Upon approval you receive an email that states "you should be able to start using it to send messages to Android 2.2 devices within the next day or so." There is no further notification confirming that you can send messages.

3) Unlike apple, a device id is not used in the notification. Android uses a registration id that they generate and send to you. The registration id is not returned when you register. It is received asynchronously and sent like a notification to your program.

4) Google can change the registration id at any time, and you need to handle it.

5) C2DM only runs on Android 2.2 and higher. However, if you set your emulator target to "Android 2.2 - API Level 8" it will not work. You need to use "Google APIs - API Level 8."

Good luck, my app still doesn't work.


No comments: