I am developing in Android for GCM. I want to implement like the following:
Phone Server <--> GCM Server <--> Phone Client
I have try to use Http post to the GCM Server , and the client can receive the broadcast data from Http Server.
But the client seems can not upstream the message to the Server via GCM by using Http.
So it need to use XMPP Server on Android side for receive the upstream message from Client. But it seems few information about this.
How to implement XMPP Server and communication with GCM on Android ?
Thanks in advance.
You may implement an XMPP Server through Google Cloud Messaging (GCM) Cloud Connection Server (CSS) is an XMPP endpoint that provides a persistent, asynchronous, bidirectional connection to Google servers. The connection can be used to send and receive messages between your server and your users GCM connected devices.
Implement the XMPP Connection Server can receive upstream messages from a user's device to the cloud. To initiate an upstream message, client app must send a request containing the address of the receiving app server, message data comprising the key/value pairs of the message's payload and a message ID should be unique.
Here's a useful documentation on how to Implement an XMPP Connection Server: https://developers.google.com/cloud-messaging/ccs
Related
I have a simple chat application installed on Android devices and can send notification via GCM HTTP.
I want to switch backend implementation from GCM HTTP to CCS XMPP.
Can I use same pntoken get from mobile devices registered previously to send push notification?
Is it required additional implementation at mobile device side?
I mean when I change the change the GCM connection interface from GCM HTTP to CSS XMPP Do I need to additional data from mobile devices?
No changes on device side are required. You can use same registration ids as before.
All of the examples I see are pushing notifications from the server to the client. How do I contact the server from the client and how would the path look?
Normal http requests can be matched using app.get('path',callback). Is this same matcher used to match gcm requests?
The GCM Cloud Connection Server (XMPP) is meant to send messages back and forth from Server to Client and from Client to server. It provides a persistent, asynchronous, bidirectional connection to Google servers. The connection can be used to send and receive messages between your server and your users' GCM-connected devices.
JSON messages are send across the network for both Upstream and Downstream messaging. Every message sent to CCS receives either an Acknowledgement or a No Acknowledgement response. Messages that haven't received one of these responses are considered pending. If the pending message count reaches 100, the 3rd-party app server should stop sending new messages and wait for CCS to acknowledge some of the existing pending messages.
For more details visit this official Google document.
To look for an app implementation where you can send messages both upstream and downstream you can take a look at this tutorial
Hope that Helps!!
Found something that might be useful. The example node.js implement xmpp server that in turn receives upstream message from device to server. Hope this helps out.
link
my team is building an android instant messaging app (like weChat or Line) and we heard that gcm can really make things easy for us
But while I was reading about google cloud messaging service, I realized that there were few components that must be thought of before doing the project
So I am guessing that there are 3 parts to gcm: gcm server, app server(3rd party), and application itself, and the question i have is with app server. I understand that gcm will work as a xmpp server, but what about the app server, does it have to be xmpp server as well? or can it be any server that can just send http request to gcm server? Thank you
There are two ways to connect to GCM server. The simple way is sending HTTP requests to GCM server. This gives you cloud to device (server to application) messaging functionality.
The more complicated way is to establish an XMPP connection with the GCM cloud connection server, which gives you both cloud to device and device to cloud messaging.
If you don't need device to cloud messaging (which mean sending messages from your application to your server via the GCM server), your server will only have to send HTTP requests to GCM server.
I'm a newbie in GCM and I have some questions:
How can I get client state from server (client is online or offline)?
How can I know my message from server is received or not?
You could send an acknowledgement from your client to your server when the client receives a message (using your own HTTP connection to your server). If you include some message identifier in your GCM message, the acknowledgement can contain that identifier, letting the server know exactly which message was acknowledged.
I would like to use GCM (Google Cloud Messaging) and was wondering if it was possible to set it up on Windows Server (IIS) instead?
Currently my web services are all hosted on Windows Servers as WCF services. I'd like to avoid having to have a dedicated server for GCM.
Instead of what? Any server connected to the internet can be used as a sender of GCM messages. Your Android application has to be able to connect your server in order to pass the device Registration ID to it. And your server has to be able to send POST requests to https://android.googleapis.com/gcm/send in order to send the messages.
Or as stated in the GCM Documentation :
Before you can write client Android applications that use the GCM
feature, you must have an application server that meets the following
criteria:
Able to communicate with your client.
Able to fire off HTTPS requests to the GCM server.
Able to handle requests and resend them as needed, using exponential back-off.
Able to store the API key and client registration IDs. The API key is included in the header of POST requests that send messages.