Can you set up GCM on windows server? - android

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.

Related

App-server communication protocol

I'm building a little android app that will connect to a server.
My app would use a simple post to send a message to my server, and I'm using Google Cloud Messaging for the server to send a message to my app.
I built a registration page, an email confirmation and a connection page but now I wonder how to lock the communication between the server and the app.
This is the protocol I have in mind ( let's take the simple exemple of app to app message) :
App send post infos to the server with self infos (like name and auth_token), destination user and the message
Server search the apps which belong to the destination user and use curl to forward the message to GCM
GCM send the message to the destination apps
How can the server be sure that the name, auth_token etc the server receive are really from the sender ?
Let the server generate the authentication token when the client is doing the registration and send this back to the client. The server now knows the [client - token] mapping.
Every time the client wants to send a message, it also sends the authentication token which the server can look up and check. The client does not even have to send his or her name, the server should know this.
To prevent MITM attacks, use a secure connection (HTTPS).
Although there are lots of solutions to secure the connection, when you are using GCM for your downsteam messages, I recommend using the new Google Cloud Messaging API which supports Upstream Messaging (from client to server).
It is very fast, reliable and secure.
Here you can find the docs
You should only change your server side from HTTP to XMPP.
Here you can find the docs.

Google cloud and xmpp server

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.

Android Push - Third party server can't log in Google GCM to be whitelisted

I am trying to test the new Android GCM API.
In the client side, everything goes good. The application can register and unregister itself properly.
In the third party server I have issues. I am testing it using the Python example server that Google provides but it can't authorize the connection with Google GCM because the project is not whitelisted. I have tried to whitelist it through this website but it always returns a 500 error.
Also, I don't want to use upstream messaging at this moment but just send messages from the server to the devices. Do I still need to be whitelisted? In that case, is there any other Google resource to do that?
You don't need to whitelist your Google API project if you are not using user notifications or Cloud Connection Server. The Python example is for Cloud Connection Server, and you don't need it for simply sending messages from your server to your app. Use the simpler HTTP API.
You can read here about GCM HTTP Connection Server.

Difference between Cloud to Device and Device to Cloud in Google GCM

I am trying to build a chat application with the Google Cloud Messaging, something similar to whatsapp. Do i need to use 'CCS: Upstream and downstream (device-to-cloud, cloud-to-device)' OR 'GCM HTTP: Downstream only: cloud-to-device' would work just fine?
GCM HTTP is easier to use and supports Cloud to Device messaging. If all you need is for your server to notify your app when a new message is available, GCM HTTP is enough.
The Cloud Connection Server is only required if you want your app to send messages to your server via its connection to the GCM servers. It's useful if your app needs to send a lot of messages to your server.

Client(android) receive messages from server(java)

I am trying to create a chat application. The communication is based on RESTful web services(Jersey). The client communicates with the server sending HTTP requests. My problem is how to send messages from server to client without the client send a request first. I read about C2DM notifications, I suppose using this way, when the client receives the notification from the server then (the client) has to send a request to the server in order to receive the data. I also was thinking about using sockets but I don't know if it is possible as I am using Rest. I mean in the server side can I also use sockets(sockets run in lower level) with the REST code? The only thing I have though that could work using sockets is to create another server with socket(two servers RESTful and socket), but is this a good solution? Also could I put some server code in the client side and some client code in the server side. Would it be correct and effective? What do you think? Which solution would be the best?
C2DM has been officially deprecated as of June 26, 2012 by google. Existing C2DM developers are encouraged to migrate to the new version of C2DM, called Google Cloud Messaging for Android (GCM).
Check out this link for more info
http://developer.android.com/guide/google/gcm/index.html
The scenario you describe sounds ideal for C2DM. If you build your own sockets set up you will drain battery and CPU resources doing something the phone is already doing - maintaining an open socket to receive messages.
C2DM is relatively straightforward to set up, and in my experience is pretty reliable.
This is the best tutorial I have seen on it:
http://www.vogella.de/articles/AndroidCloudToDeviceMessaging/article.html
But you also need to read the official docs:
http://code.google.com/android/c2dm/
Your server-side code will need to send an HTTP request to the C2DM servers to send a message to a device. To tell it where to send the message, your server needs to specify the Registration ID (which represents your app running on one specific device) and so when your app sets up on the Android device, it registers with C2DM, and then needs to send its C2DM Registration ID to your server to be stored, ready to be used to send messages to.

Categories

Resources