简体   繁体   中英

How to use Google Cloud Connection Server to send upstream GCM message

I am trying to send an upstream message from device to cloud using the new Cloud Connection Server feature of Google Cloud Messaging. I am using the example code in Getting Started guide.
http://developer.android.com/google/gcm/gs.html

I am able to set up the client side and am getting the registration ID. But when I send the message to the server nothing happens. I am not sure if I need to do some setup at the server end.My basic server requirement is to receive the message from the client and send a response back. I am using a Java based backend server.I could not find anything concrete in the documentation regarding server side set up.

Can anyone please help ?

Yes this is definitely possible
http://developer.android.com/google/gcm/ccs.html

The GCM Cloud Connection Server (CCS) allows third party servers to communicate with 
Android devices by establishing a persistent TCP connection with Google servers using the 
XMPP protocol. This communication is asynchronous and bidirectional.

You can't just register to GCM at the client side and send messages to your server. That only takes care of the connection between your device and the GCM server.

You have to set up your server's connection to the GCM Cloud Connection Server (CCS) in order to be able to send and receive messages at your server :

GCM Cloud Connection Server (CCS) is an XMPP endpoint, running on http://gcm.googleapis.com port 5235.

CCS requires a Transport Layer Security (TLS) connection. That means the XMPP client must initiate a TLS connection. For example in smack, you would call setSocketFactory(SSLSocketFactory), similar to “old style SSL” XMPP connections and https.

CCS requires a SASL PLAIN authentication mechanism using @gcm.googleapis.com (GCM sender ID) and the API key as the password, where the sender ID and API key are the same as described in Getting Started.

You can use most XMPP libraries to interact with CCS.

GCS is currently in beta and requires you to apply for it. Quoting the documentation page:

Note: To try out this feature, sign up using this form .

Did you sign up? After that Google should get back to you and give you access to the service.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM