I have successfuly send data from php server page to android client with JAXL..
I have read carefully the guide of Google Cloud Message Offical website.. For Upstream there is only these documents:
public void onClick(final View view) {
if (view == findViewById(R.id.send)) {
new AsyncTask() {
@Override
protected String doInBackground(Void... params) {
String msg = "";
try {
Bundle data = new Bundle();
data.putString("my_message", "Hello World");
data.putString("my_action","SAY_HELLO");
String id = Integer.toString(msgId.incrementAndGet());
gcm.send(SENDER_ID + "@gcm.googleapis.com", id, data);
msg = "Sent message";
} catch (IOException ex) {
msg = "Error :" + ex.getMessage();
}
return msg;
}
@Override
protected void onPostExecute(String msg) {
mDisplay.append(msg + "\n");
}
}.execute(null, null, null);
} else if (view == findViewById(R.id.clear)) {
mDisplay.setText("");
}
}
Say this:
Receive XMPP messages on the app server
When GCM receives an upstream messaging call from a client app, it generates the necessary XMPP stanza for sending the upstream message.
GCM adds the category and from fields, and then sends a stanza like the following to the app server:
<message id="">
<gcm xmlns="google:mobile:data">
{
"category":"com.example.yourapp", // to know which app sent it
"data":
{
"hello":"world",
},
"message_id":"m-123",
"from":"REGID"
}
</gcm>
</message>
But now I have some questions,because of limited documents for upstream.
1-)Android send JSON data, with sender id for upstream... But when I register to api,have not been asked about app server. Sender Id identfy my gmail account's application with package. Not app server. so where gcm send data that come by client? How to GCM knows my app server..
2-)I have limited budget, my server is shared account web server. So I have to use php... But I have read on document,"Your app server should be persistent connection" not connect& disconnect regularly... Can I use app server as php? that GCM connects Php scrpit which evulate data and respond back to android client?
As you may know, the connection between your server and GCM required sender-id and API key. Also when a client app wants to send an upstream message, it uses the same sender-id. So GCM knows to whom it should send the upstream data.
There is no limit on your programming language, of course you can use PHP. You just have to maintain a persistent connection to GCM server.
Don't care about some disconnections, note that Google will retry to send the upstream messages if your server was down, and didn't send an ACK back to GCM for a particular message.