This is an effort to develop a Android application which enable C2DM
Things I have done correctly
- Get a valid Gmail address with C2DM
- Write an Android app for getting a registrationId from C2DM
- Get that registrationId from C2DM
- Pass that registrationId to the third party server (I sent to a php
page) (1) - Send it correctly (I checked it with the HttpEntity class in the same
android app and I got the content of that page) - Getting Google authentication ID in server side (used PHP)
- Open a Gmail account in my emulator (Menu – Settings – Accounts & sync – Add acount)
Things I am confused
-
How that web page (1) get notified when my Android app passed a “http” request?
-
How can I display the registrationId in the web page which sent by my Android app?
Things that wont work
-
Sending PushNotification to the emulator which runs my Android app. Referred this. That code is really good and first part also woks for me. But when I run the sendMessageToPhone() function it sends me 401. In my code I hard coded the values for;
-
$authCode = Google authentication code I get
-
$deviceRegistrationId = Code sent by the C2DM to my Android app
So please help me to clear my confusions and to correct my “wont work” activities.
Here is a simplest code for sending POST request to PHP:
On server side(i.e. in your PHP script) you can use $_POST superglobal variable which is populated from POST data and it’s a simple associative array. Something like this: