Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

c2dm sends push notifications to Android devices via google c2dm.

branch: master

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 .document
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Gemfile
Octocat-spinner-32 Gemfile.lock
Octocat-spinner-32 LICENSE.txt
Octocat-spinner-32 README.markdown
Octocat-spinner-32 Rakefile
Octocat-spinner-32 VERSION
Octocat-spinner-32 c2dm.gemspec

C2DM - Google Cloud to Device Messaging Service

c2dm sends push notifications to Android devices via Google c2dm.


$ gem install c2dm


An Android device running 2.2 or newer, its registration token, and a Google account registered for c2dm.


First you will need to authorize with google to get your ClientLogin auth token.

Use the credentials for the app you've registered with Google.

C2DM.authorize("", "password")

This sets auth_token for future requests.

You can also use cURL to get the AUTH= parameter:

# curl -X POST -d Email=<email> -d Passwd=<password> -d accountType=HOSTED_OR_GOOGLE -d service=ac2dm

We suggest you store the token and set it in your config files:

C2DM.auth_token = "YOUR_AUTH_TOKEN"

You can also set it in your environment:


If you'd like to set a custom source param for debugging, set:

ENV["C2DM_AUTH_TOKEN"] = "CompanyName-AppName-1.0"

Send a notification

Send a single notification:

  :registration_id => "...",
  :message => "Hi!",
  :extra_data => 42,
  :collapse_key => "some-collapse-key"

The only required key is :registration_id. You may also pass :collapse_key, but it's optional.

All other keys will be sent as "data.<key>". This is the payload of your notification.

Sending Multiple

You can also send multiple notifications at once.

notifications = [
    :registration_id => "...", 
    :message => "Hi!",
    :extra_data => 42
    :registration_id => "...", 
    :message => "Bye!",
    :extra_data => "BOOM",
    :collapse_key => "some-collapse-key"



  • Send multiple notifications concurrently using Typhoeus::Hyrda


  • Copyright (c) 2010 Amro Mousa, (c) 2011 Brandon Keene. See LICENSE.txt for details.
Something went wrong with that request. Please try again.