Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
This repository is a collection of applications that was put together with the sole purpose of demonstrating the basic functionality of Google's Cloud to Device Messaging (c2dm)
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
pushprototype-android
pushprototypedjango
README.rst

README.rst

PushPrototype

About

This repository is a collection of applications that was put together with the sole purpose of demonstrating the basic functionality of Google's Cloud to Device Messaging (c2dm). For more on the service, refer to http://code.google.com/android/c2dm/index.html

There are two applications, an Android app and a Django app. The django app was built with Django 1.2 on top of python 2.7.1 and the Android app using version 2.2 of the API. Refer to http://developer.android.com/sdk/index.html and http://docs.djangoproject.com/en/dev/intro/install/ for more on setting up those environments.

Setup

Aside from the exceptions below, these apps are pretty vanilla Android and Django configurations.

  • If you haven't already, you'll need to register your gmail or google apps address here: http://code.google.com/android/c2dm/signup.html

  • Before running the Django application, rename pushprototypedjango/push/authentication.default.py to pushprototypedjango/push/authentication.py:

    mv pushprototypedjango/push/authentication.default.py pushprototypedjango/push/authentication.py
    
  • Modify the newly moved file and follow the directions. You'll need to run the following from the console in order to retrieve your authentication token (curl with ssl libraries required: http://curl.haxx.se/):

    curl https://www.google.com/accounts/ClientLogin -k --data-urlencode Email=youraccount@gmail.com --data-urlencode Passwd=some_password -d accountType=GOOGLE -d source=com.patrickbaumann.pushprototype -d service=ac2dm
    
  • The response will contain an SID, AUTH, and LSID:

    SID=alsdjfa;ljsdf;lajsdlfj...
    AUTH=alsdjkfa;lskjdfl;asjd...
    LSID=asl;dfjalskdjflasjdfl...
    
  • Paste the AUTH line after the '=' into authentication.py between the quotation marks.

  • In order to build the android application, you'll need to download and include the jars that are released as part of the Apache HttpClient libraries in your build path. You can download the latest libraries here: http://hc.apache.org/downloads.cgi

  • Before building your Android app, copy res/values/settings.default.xml to res/values/settings.xml, delete the lines with "REMOVE THIS LINE" and replace the email in the file with the email address you registered for the c2dm service.

Running

  • Once you've cloned the repository, navigate to the /c2dmprototype/pushprototypedjango directory and start a development server by running

    python manage.py runserver 0.0.0.0:8000
    
  • On your android phone or emulator with the official Google Android API 8 image, add a Google account to your phone via Settings -> Accounts & Sync -> Add Account -> Google. This is necessary in order to properly register the phone with the Google server.

Something went wrong with that request. Please try again.