In GCM, there are three main components
GCM server
third party app server
client (mobile)
Which one of them stores the data that is to be pushed?
For example, if a mobile1 has to communicate with a mobile2 and it wants to send a message "HI" and an image, then where does this two pieces of data get stored, on the app server, or on the GCM server?
You are not expected to send pushes from one mobile to another. You need the data to get through a server (given your tags, possibly an XMPP server or anything else).
It means that data get indeed store on your own server not GCM.
Not that GCM does not do image transfert. You should only transfert notification about the fact that an image is available somewhere to download.
Found out a solution the flow is like from
app server to ccs to gcm
Related
I am trying to make a simple messaging app that has a mysql and php server with an android app. My back end revolves around mysql to store and php to communicate from the database to the device and vise versa.
Now, what I am trying to accomplish is this: sending device->GCM->target device.
What I had in mind was that the database I created stores the gcm Id for all user. That way, when a user wants to send a message, their app sends a message to my database to be stored and retrieves the targets gcm Id and then sends the targets gcm id to the gcm servers to create the push notificiation. When the target receives the gcm message, it sends a response to the database to receive the actual sent message.
Is this possible, and how would I go about doing this?
I already have a gcm receiver implemented from here:
https://github.com/codepath/android_guides/wiki/Google-Cloud-Messaging
No. Don't do it.
For any internet connected device (server or mobile) to request a push to a device, it needs to send a POST request to the GCM address (https://gcm-http.googleapis.com/gcm/send) passing the server API key and the device GCM reg id which should receive the message. And having any of those values available on a device is a security risk for your application.
Having your registration ID, means ppl could easily "copy" your ID and start sending messages from their servers on your behalf.
The GCM device registraion ID, means anyone could start spaming your users, and you certainly don't want that.
You could look into GCM Upstream (https://developers.google.com/cloud-messaging/upstream) but that only means your client code will be easier, as it's as simple as calling gcm.send(String);, but you still have to handle that on your server application.
The correct way is to have on your server a table that maps userId with gcmRegId and have devices send to your server messages to their desired userId. Your server should process one device "send" message and create a push to the other device. That logic should be fairly simple on the server side, after you already have a whole chat application developed.
Can we send the message from Android Device to GCM server?
I am implementing the Total GCM functionality to get message from server and it works fine.
Now i want to save that message response right now i am using separate webservice to store response to server,
Can i do that using GCM instead Webservice?
No you can't. You need to create XMPP server for that. You can see brief answer here
You can check example of chat here
GCM is only a system to deliver messages to registered devices. It is not responsible for any other activity.
If you want to store data, that will need to be on your registered device or your web service.
I would like to implement GCM in my Android app:
One Android app
Registered- U_user and another M_user.
I have Google Sign In in my app thats works fine with JSON and GSON and local MySQL database server with tomcat-server restutil to keep storing Gmail login users.
So, I want to send a notification from U_user to M_user.
U_user does a registration that has been pushed to M_user.
How can I do this?
I am assuming you mean the same Android app installed on different phones (U_user's phone and a separate phone for M_user).
To quote a section in the docs:
To make sure that messages go to the intended user:
Your app server can maintain a mapping between the current user and the registration ID.
The app can then check to ensure that messages it receives match the logged in user.
What this means is that you can send messages to another user through GCM. To let the app server know what to send to M_user, let U_user send an upstream message to your GCM app server (only possible in app servers using XMPP - see here). Alternatively, you have the option to do POST requests to your app server via HttpUrlConnection (can work on both XMPP- and HTTP-based GCM app servers).
Regardless of which method you use, specify in these messages to the server that you would like to send a message to M_user.
I need to implement a group chat server which can support more than 50 users at a time.
The users will be only on mobile clients which include Android/Windows Phone.
Sending push notifs to the apps will not be difficult, as the server needs to do a basic curl request. So "polling" is not an issue.
My current skill set includes.
Flask
Google App Engine( I intent to use it or a web hosting
server.)
Basic php
So from what I know, I can make http requests to the server with user specific information+chat msg.
The server processes this and sends a broadcast using push notifs to all the devices stored in database.The server identifies the device from the data in the http request.
How efficient will this be?
If this is not the correct approach, what all do I need learn(sockets programming?) and any framework which can make my work easier (it will help if it is also supported on GAE).
I think you need XMPP messaging. It's support by App Engine but not in PHP : https://developers.google.com/appengine/features/
XMPP permit to send and receive chat messages.
I am trying to learn GCM and is currently reading the documentation:
connection servers take messages from a 3rd-party application server (written by you) and send them to a GCM-enabled Android application (the "client app," also written by you) running on a device.
Now in my other applications that needs a "Larger" amount of data i have done the following steps:
Send data to server (HTTP post)
Recieve data from server (JSON) (using GSON)
Now as far as i can read from the documentation what this will do is add a middle step which is only usefull if the device i am trying to send to is offline.
my question is:
I am trying to create an instant messaging application, what should i use on my server side? is PHP enough to just instantly send the data to GCM or should i use another server software that can handle these huge chuncks of request, such as Message queue?