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

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.

Related

Send firebase cloud message from client without exposing API secret

I'm developing a new chat application that currently works with firebase realtime database and cordova.
I was looking for a backend-less solution since my currently working app doesn't need any server at all apart from a tiny server that its only function is to provide with temporal authorization tokens for the clients.
This tokens allow the client to work directly with firebase without the need for a more expensive and loaded server, and still have a central control for the usage of the app.
By reading the new firebase documentation I believe that the notifications and the firebase cloud messages app can't be used by the client side to post messages, only to listen notifications since all the send message examples expose the server API key, which obviously can't be on the client side.
Is there a way to issue temporal tokens from a central server that can be used by the clients to send messages instead of having to send all the messages to the server and then back to the other devices?
Thanks
Sending downstream messages to devices with Firebase Cloud Messaging requires access to the authorization key. For that reason it should run in a trusted process, such as on hardware you control.
Cloud Functions for Firebase was launched today, which would solve your problem! You can initialize the firebase-admin SDK within your functions code (which runs on Google's servers, not client side), and use it to access FCM. That way you can send messages in response to new database items, or in response to HTTPS requests.
Here's an intro to Cloud Functions for Firebase: https://firebase.google.com/docs/functions/
Here's how you can use firebase-admin to send FCM messages:
https://firebase.google.com/docs/cloud-messaging/admin/send-messages

IM client and servers

Can anyone explain how to make a basic IM client with my old PC as a server, client can be on IOS or android? And also please explain how to work with IM and servers simultaniously.
For android you could use Google Cloud messaging and a similar messaging service for IOS. When a client send's a message, it should be sent to GCM via upstream service and GCM will push the message to the server. The server will house the deviceId's of the client's and can push a message whenever required to the client by making a API call to GCM with the message and the deviceID.
Check the documentation for GCM and you will get a clear idea.
There are also other services like GCM which can work for android as well as IOS
The reason for using such a service is that it ensures that the messaging is full proof. Even if the client is not having internet connectivity or is switched off, it shall receive the message on getting internet connection. You do not have to handle those troubles!

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.

What is the primary usage of upstream messaging in GCM Cloud Connection Server?

What is the usage of Cloud Connection Server that was announced at Google IO 2013?
I'm interested to know whether I can use the upstream messaging feature to send specific messages to GCM server. For example, can I send a command to delete a GCM notification that is stored on the GCM server? Or is it only used to send custom messages? If so, why do we need it at all?
According to the docs, there is no such feature to delete messages from the GCM server.
The upstream feature serves only for delivering messages from the device to your 3rd-party server. The advantages of using device to cloud messaging instead of establishing your own connection between your app and your server is improving battery life. It's also supposed to be faster than the regular GCM (since it's asynchronous).
Some of the benefits of CCS include:
The asynchronous nature of XMPP allows you to send more messages with fewer resources.
Communication is bidirectional—not only can the server send messages to the device, but the device can send messages back to the server.
You can send messages back using the same connection used for receiving, thereby improving battery life.

Can you set up GCM on windows server?

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.

Categories

Resources