Williams Williams - 11 months ago 80
Android Question

Upstream messaging in Android

I am doing work on GCM (Google Cloud Messaging) in Android. I am looking for the upstream message using GCM.

Code send the GCM messages to cloud here

try {
Bundle data = new Bundle();
// the account is used for keeping
// track of user notifications
data.putString("account", account);
// the action is used to distinguish
// different message types on the server
data.putString("action", Constants.ACTION_REGISTER);
String msgId = Integer.toString(getNextMsgId());
gcm.send(projectId + "@gcm.googleapis.com", msgId,
Constants.GCM_DEFAULT_TTL, data);
} catch (IOException e) {
"IOException while sending registration id", e);

Now question is that what cloud would do for that upstream message, Where it can be useful in Android and How ??

Answer Source

When you send an upstream message from your app, the GCM Cloud Connection Server (CCS) transfers that message to your server. In order for that to work, you must implement a server that supports XMPP protocol and establishes a TLS connection with GCM Cloud Connection Server. You also need your API project to be white-listed for using this feature. You can read more about it here.

As for usefulness, it allows you to send messages to your app via the GCM connection instead of via your own connection between your app and your server. That's more battery efficient.