gae-python-gcm is a simple implementation of Google Cloud Messaging for Google App Engine in Python.
This module is designed to take care of everything you have to think about when working with Android GCM messages on the server:
- Takes advantage of App Engine's task queues to make retries asyncronous
- Uses App Engine's memcache to collect error statistics
- Provides two hook functions, delete_bad_token and update_token, which can be overridden or configured from a settings files to implement these actions in your environent.
- Example django settings and testing / debug handlers.
gae-python-gcm can be used with or without Django. The provided example was taken from a django-nonrel enviroment and is based on the way we use it at Pulse. If you want to use it with App Engine's built-in Django or without Django at all, it should be relatively simple to take the core functionality in /gae-python-gcm/gcm.py and leave the rest. Feel free to contact me if you have any quesitons (@gregbayer).
We prefer to keep everything in Python instead of using the GCM server referance implmentation in Java.
from gae_python_gcm.gcm import GCMMessage, GCMConnection
gcm_message = GCMMessage(push_token, android_payload)
gcm_conn = GCMConnection()
gcm_conn.notify_device(gcm_message)
To add gae-python-gcm to your AppEngine project without Django:
- git clone git://github.com/gregbayer/gae-python-gcm.git
- Add entries to your app.yaml and queue.yaml based on included files.
- Copy the gae-python-gcm directory into your appengine project
- Make sure you set YOUR-GCM-API-KEY in /gae_python_gcm/gcm.py or in the settings module.
To add gae-python-gcm to your AppEngine project with Django:
- git clone git://github.com/gregbayer/gae-python-gcm.git
- Add entries to your app.yaml and queue.yaml based on included files.
- Copy the gae-python-gcm directory into your appengine project
- Configure your project as appropriate. You may find the urls.py and settings.py examples in the example_django_files directories useful.
- Make sure you set YOUR-GCM-API-KEY in /gae_python_gcm/gcm.py or in the settings module.