Imagine you are developing an Android app that need to receive push notifications. The application in charge of sending them to GCM is being developed by another team, and not only is not finished yet, but also that team may be in another department, or even in another company. You want to make sure your Android app fullfill the specifications (i.e it reacts in a way when receives a certain push notification), but you don’t want to depend on that other team (and neither want to develope a sender app yourself 😀 ).
Well, that need of a configurable GCM sender app is the second artifact Adrian Santalla and I developed in our two first OSOCO’s hacker fridays, (being the first the Grails Android GCM plugin), the Android GCM Sender.
Started as a test app for the plugin, we felt it would be easy to evolve it until the point of being useful to anybody: we just needed to parametrice the project ID (that you will get by creating a Google API project) and create an action that let Android devices subscribe. You can visit the Android GCM sender in the following URL: http://grails-android-gcm-sender.herokuapp.com/.
The first step would be to subscribe your Android device ID using the URL http://grails-android-gcm-sender.herokuapp.com/device/subscribe?deviceToken=yourDeviceToken&projectId=yourProjectId. Don’t forget to substitute yourDeviceToken and yourProjectId with your project ID and Android device token, and remember that this URL is designed to be invoked through some kind of HTTPBuilder inside the Android app – that’s why it doesn’t any output :-). But if you want to use it directly in your browser you can do that as well 😀 .
After that, write your project ID in the Android GCM Sender homepage form and press the refresh button. You will be presented a form that allows you to send a message (simple or composed) to one or many Android devices. Please note that two fake devices will be always available in case you want to do some tests with them. After filling the form, you can press the Send button, and the message result will be shown to you. And if your device ID and project ID are valid ones, you should receive a push notification with the message you composed in the previous view :-D.
Please bear in mind that, in order to keep our data small, your device and project ID are only kept for 24 hours – think of it as a feature 😀 since you don’t have to worry about unsubscribing and stuff like that. In fact, since the database is in memory, we don’t have access to it.
The Android GCM sender is up and running in Heroku, but you can see the source code in OSOCO’s Github account, and even host it yourself if you want. The app is developed using Grails, and the UI is spiced up with Ajaxify.