Thursday, July 19, 2012

Dude - Where is my C2DM?

So a project we're working on at Technoracle requires push notifications.  For iOS builds we are using Apple's APNS, which is very secure and reliable.  I had an issue with C2DM and went to the Google Developer website and was blind sided by this message:




Dang!  For the uninitiated, C2DM is Cloud to Device Messaging.  Those little red notifications you see on your phone letting you know that you have actionable items to look at works by a small daemon running in the background at all times, waiting for messages.  The messages are composed of several logical parts but the basic message contains a section describing the application destination, then another about the message.

C2DM vs GCM?

So what is GCM and why is it better?  Google Cloud Messaging is built from the lessons learned from C2DM, or so it appears to us.  Like C2DM, it's main purpose is to transfer messages to Android powered devices to let them know there is a message on a server waiting for them to do something with.  C2DM was very lightweight and easy to implement.  GCM offers some improved options.  From the google GCM website:

"a lightweight message telling the Android application that there is new data to be fetched from the server (for instance, a movie uploaded by a friend), or it could be a message containing up to 4kb of payload data (so apps like instant messaging can consume the message directly). The GCM service handles all aspects of queueing of messages and delivery to the target Android application running on the target device."

We are excited to try it and look forward to this improvement.

More reading:

To learn more about GCM, you can join the android-gcm group and read the following documents: 

Getting Started  Read this document to learn the basic steps involved in developing Android applications based on GCM.

Architectural Overview Read this document for a description of the underlying concepts and architecture in GCM.

Demo App Tutorial Read this document to walk through setting up and running the GCM demo app.

Advanced Topics Read this document to get a more in-depth understanding of key GCM features.

Migration Read this document if you are a C2DM developer moving to GCM.

GCM also provides helper libraries for client and server development.

12 comments:

  1. Hi there, wonder how the migration went to GCM. I find the Migration doc rather skinny and wondered if you had any issues or tips you could share...

    ReplyDelete
  2. I haven't done a migration yet. Got hit hard by a car while riding my bike and have been unable to work for past week. I had similar thoughts too with the documentation. Some things I had noted are that OAuth and Client logins are now deprecated (makes sense to some degree to enforce stricter control) and JSON support. This is more aligned with APNS now.

    Did you migrate over? There are sure to be a few kinks.

    ReplyDelete
  3. Does the C2DM notification service still works?

    ReplyDelete
  4. Does the C2DM notification service still works?

    ReplyDelete
  5. Yes - it currently still works but all new apps should be written using GCM.

    ReplyDelete
  6. When I try to receive push Notifications I received these errors at the moment of receive notifications with this url: https://android.apis.google.com/c2dm/send:


    dmControl: registrationId = null, error = SERVICE_NOT_AVAILABLE, removed = null

    Registration error SERVICE_NOT_AVAILABLE

    Error when trying to recover the notification token from C2DM. Error id: SERVICE_NOT_AVAILABLE

    And the device displays the message: Google service is not available. Try again

    Do you have this problem with push notifications or any idea to solve my problem?

    ReplyDelete
  7. When I try to receive push Notifications I received these errors at the moment of receive notifications with this url: https://android.apis.google.com/c2dm/send:


    dmControl: registrationId = null, error = SERVICE_NOT_AVAILABLE, removed = null

    Registration error SERVICE_NOT_AVAILABLE

    Error when trying to recover the notification token from C2DM. Error id: SERVICE_NOT_AVAILABLE

    And the device displays the message: Google service is not available. Try again

    Do you have this problem with push notifications or any idea to solve my problem?

    ReplyDelete
  8. It looks like the server you are using is not accepting C2DM registration. How are you sending it?

    ReplyDelete
  9. I had an account that was already registered

    ReplyDelete
  10. I was using an account that was already registered, and it was working on December, but currently push notifications stopped working

    ReplyDelete
  11. sorry for the spam, we migrated to the new notification system and now everything works fine

    ReplyDelete
  12. Ricardo:

    Definitely not spam. This is helpful info for others. Thank you for sharing here.

    Duane

    ReplyDelete

Do not spam this blog! Google and Yahoo DO NOT follow comment links for SEO. If you post an unrelated link advertising a company or service, you will be reported immediately for spam and your link deleted within 30 minutes. If you want to sponsor a post, please let us know by reaching out to duane dot nickull at gmail dot com.