简体   繁体   English

如何使用Google Cloud Connection Server发送上游GCM消息

[英]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. 我正在尝试使用Google Cloud Messaging的新Cloud Connection Server功能将上游消息从设备发送到云。 I am using the example code in Getting Started guide. 我正在使用“入门指南”中的示例代码。
http://developer.android.com/google/gcm/gs.html http://developer.android.com/google/gcm/gs.html

I am able to set up the client side and am getting the registration ID. 我能够设置客户端并获得注册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. 我使用的是基于Java的后端服务器。我在有关服务器端设置的文档中找不到任何具体内容。

Can anyone please help ? 有人可以帮忙吗?

Yes this is definitely possible 是的,这绝对是可能的
http://developer.android.com/google/gcm/ccs.html 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. 您不能只在客户端注册GCM并向服务器发送消息。 That only takes care of the connection between your device and the GCM server. 这只关注您的设备和GCM服务器之间的连接。

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云连接服务器(CCS)的连接,以便能够在您的服务器上发送和接收消息:

GCM Cloud Connection Server (CCS) is an XMPP endpoint, running on http://gcm.googleapis.com port 5235. GCM云连接服务器(CCS)是一个XMPP端点,在http://gcm.googleapis.com端口5235上运行。

CCS requires a Transport Layer Security (TLS) connection. CCS需要传输层安全性(TLS)连接。 That means the XMPP client must initiate a TLS connection. 这意味着XMPP客户端必须启动TLS连接。 For example in smack, you would call setSocketFactory(SSLSocketFactory), similar to “old style SSL” XMPP connections and https. 例如在smack中,你会调用setSocketFactory(SSLSocketFactory),类似于“旧式SSL”XMPP连接和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. CCS需要使用@ gcm.googleapis.com(GCM发件人ID)和API密钥作为密码的SASL PLAIN身份验证机制,其中发件人ID和API密钥与“入门”中所述的相同。

You can use most XMPP libraries to interact with CCS. 您可以使用大多数XMPP库与CCS进行交互。

GCS is currently in beta and requires you to apply for it. GCS目前处于测试阶段,需要您申请。 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. 之后,Google应该回复您,并授予您访问该服务的权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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