I am trying to implement a messaging service using GCM's CCS...I have already implemented GCM in normal way where I used a third-party server and browser key with GCM Sender id to send notification to devices, which works perfectly.
I have tried implementing CCS using the following link
Which has two project one is for Android and another one for Java. I am not worried for the server application for time being because I can use PHP features too. However I am not finding a way where Android application is connecting with server application in the code and other examples have same unrealistic ending to the project. If at all I can send the registrationId to my server using HTTP connection, how would I able to send upstream message to GCM-CCS from application?
I want that one device will send a message to CCS Application and that message will be broadcast to all registered devices including the sender.
The following link for tutorial is a bogus link too, I don't understand what its trying to do.
Google must provide a clear representation about CCS-GCM.
Please refer this link -
http://developer.android.com/reference/org/apache/http/client/methods/HttpPost.html
a small tutorial- http://www.androidhive.info/2011/10/android-making-http-requests/
for sending messages from app to backend , you can use json encoding . and POST parms to url or yours server , do something like this -
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("message", post_message));
Log.d("request!", "starting");
//Posting user data to script
JSONObject json = jsonParser.makeHttpRequest(
POST_URL, "POST", params);
Where JSONObject is yours json parser Sir
a good json parser tutorial - http://eclipsesource.com/blogs/2013/04/18/minimal-json-parser-for-java/
As per yours edit , After yours backend recieves the messages encoded in json , save them in database and then finally use GCM to send messages to all the registered device
I think you need to use an XMPP connection to send upstream messages. See https://developers.google.com/cloud-messaging/ccs#upstream for a description of upstream messaging along with sample code. (This is also where I learned that you need to use XMPP instead of HTTP. Sorry I don't have more specific answers to offer at the moment, I'm still working out how to do this myself.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.