The updated files and tutorial are available here: http://www.b4x.com/forum/basic4andr...ush-notification-c2dm-framework-tutorial.html
Google provides a push service for Android. Using this service requires building several components. This framework simplifies the process of adding push notification support for your applications.
This is the first beta which should be considered a proof of concept. I think that the usage of this framework is surprisingly simple (compared to implementing all the required components yourself).
Next week the first version will be released together with a complete tutorial. For now you are more than welcomed to download and play with it. Later it will be easy to continue with the stable version.
The official documentation about C2DM service is available here: Android Cloud to Device Messaging Framework - Google Projects for Android
It is recommended to go over it.
The framework consists of three components:
- Client application which includes the code required for registering the device and handling the messages. This is the code that will be integrated in your application.
- Desktop command line tool that sends the messages.
- A php script that manages the registrations. Currently the desktop and device programs are configured to use the script hosted on this site. The script itself will be included in the stable release.
How to configure this framework
First you need to register with Google: Sign Up for Android Cloud to Device Messaging - Google Projects for Android
Remember the package name you provided to Google as you will need it later.
From my short experience it took a couple of hours till my account was approved.
Unzip the desktop component and edit config.txt.
You should enter the mail address you provided and the account password.
Unzip and open the B4A program.
Update the two following fields in Sub Process_Globals in the main activity:
Package is your application package name. It should be the same as the name provided when you sign up. You should also set the application package name by choosing Project - Package name.
SenderId is the mail address (ex: [email protected]).
Edit AndroidManifest.xml (located in Objects folder) with a text editor and replace all occurrences of: anywheresoftware.b4a.samples.push with your package name.
Run the client application
Enter a unique name and press Register. You will later use this name to send messages to this device. A good name can be your forum user name.
After a few seconds you should see a toast message saying that registration was successful or an error message. The message should also appear in the logs.
If registration was successful then it's time to send some messages...
Go to the folder of the desktop component and open a command window (in Windows 7 and Vista it can be done by pressing shift together with right click on the folder icon).
Now run b4a_c2dm.bat with the following arguments:
send <device name> <message>
The device should show a toast window with this message. Note that it doesn't matter whether the program runs or not.
Questions and feedback are welcomed...
Google provides a push service for Android. Using this service requires building several components. This framework simplifies the process of adding push notification support for your applications.
This is the first beta which should be considered a proof of concept. I think that the usage of this framework is surprisingly simple (compared to implementing all the required components yourself).
Next week the first version will be released together with a complete tutorial. For now you are more than welcomed to download and play with it. Later it will be easy to continue with the stable version.
The official documentation about C2DM service is available here: Android Cloud to Device Messaging Framework - Google Projects for Android
It is recommended to go over it.
The framework consists of three components:
- Client application which includes the code required for registering the device and handling the messages. This is the code that will be integrated in your application.
- Desktop command line tool that sends the messages.
- A php script that manages the registrations. Currently the desktop and device programs are configured to use the script hosted on this site. The script itself will be included in the stable release.
How to configure this framework
First you need to register with Google: Sign Up for Android Cloud to Device Messaging - Google Projects for Android
Remember the package name you provided to Google as you will need it later.
From my short experience it took a couple of hours till my account was approved.
Unzip the desktop component and edit config.txt.
You should enter the mail address you provided and the account password.
Unzip and open the B4A program.
Update the two following fields in Sub Process_Globals in the main activity:
B4X:
Package = ""
SenderId = ""
SenderId is the mail address (ex: [email protected]).
Edit AndroidManifest.xml (located in Objects folder) with a text editor and replace all occurrences of: anywheresoftware.b4a.samples.push with your package name.
Run the client application
Enter a unique name and press Register. You will later use this name to send messages to this device. A good name can be your forum user name.
After a few seconds you should see a toast message saying that registration was successful or an error message. The message should also appear in the logs.
If registration was successful then it's time to send some messages...
Go to the folder of the desktop component and open a command window (in Windows 7 and Vista it can be done by pressing shift together with right click on the folder icon).
Now run b4a_c2dm.bat with the following arguments:
send <device name> <message>
The device should show a toast window with this message. Note that it doesn't matter whether the program runs or not.
Questions and feedback are welcomed...