C2DM using IBM










Push Notification service using IBM C2DM for Ubuntu 10.04


The goal of my work on push notifications was to develop a working demo, which is what all other examples out there lack. I am happy to say that I accomplished my objective. You can download the sample android app on GitHub.


This app (shown on the left) has a TextView and two buttons. The TextView contains your device ID and the buttons are used to start and stop the push notifications service. Once you have the app on your phone, start the service.



You can see the source code for andoid-push in this GitHub project. It contains the aforementioned send_mqtt.php script.


If you did not get a notification, make sure you have network connectivity. It can also be that the broker is down on my server (see server status on the page). If that is the case, please post a comment and I will look into it bringing the broker back up.







1) You need the message broker software to run on the server.


You can download one for free from IBM alphaWorks.
What you get is a zip file with versions of the server software for a variety of platforms, including the obvious (Windows, Red Hat, Ubuntu, Mac OS, etc.).

It is very configurable, but for now, you can just run the executable and the server is running.



2) Rename the Downloaded Server Folder to push and place the folder into your /var/www/




3) You have to change the lines of code in send_mqtt.php in push directory under /var/www/




 i.e: $conn->connect(SAM_MQTT, array(SAM_HOST => '127.0.0.1',SAM_PORT => 1883));



change it to



$conn->connect(SAM_MQTT, array(SAM_HOST => 'Live Ip address',SAM_PORT => 8080));



4) Run the server



 -> goto Downloads Directory


 -> under that goto rsmb_1.2.0 Directory


 -> under that goto linux_ia32 Directory


 -> then, run the broker file using this command ./broker



5) Run the android application on android external device. This shows Android Device Id and two buttons to start/stop Push Service on the client. Start the service



6) Run this below url on your Browser.



 i.e: http:///push/index.php



7) Finally, in the resulting webpage Enter the Device Id(Android device Id) and text message then click on submit button.


 A new status bar notifications comes to your device.







0 comments: