Is it possible to use GCM with a python GAE backend?

google-app-engine, google-cloud-messaging, push-notification, python, webserver

Solution

Sure you can. GCM has a JSON REST API that you can work against. First you need to register you project here: http://developer.android.com/google/gcm/gs.html.

You basically do this:

- Acquire you API key from http://developer.android.com/google/gcm/gs.html#access-key

- Construct your payload, a dict containing registration_ids, data etc

- Using url.fetch https://developers.google.com/appengine/docs/python/urlfetch/ to send the data as a JSON string to the GCM API

Here's another question with some code. Google Cloud Messaging HTTP Error 400: Bad Request and a blogpost (in not english, i think spanish. but there some sample code) http://pforray.wordpress.com/2012/07/05/ejemplo-gcm-en-appengine-python/

Problem

I have a python GAE service, and I want to push notifications from the server to devices. The tutorial available for GCM is written for Java, and runs on ant+Tomcat/Jetty+JAE. I was under the impression that GCM would be a language-agnostic web service, and that I would be able to send push notifications regarding of my server-side platform. - Was I mistaken about GCM being compatible with my python GAE backend? - If I CAN use it with my existing server, what instructions can I follow (or adapt) to get started with sending notifications to a mobile client?

Original source