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.
Related
I implemented an Android chat application using Smack client with XMPP server. Everything works fine when the user is online, now when the user is offline (the app is not in running state). I would like to push notification using GCM.
Is there a way to achieve that, and is there a way that we can manage our server itself to take care of that?
I'm facing this problem too.I'm solving this as folowing steps:
Develope a WebService (ASP or PHP or ...) with a database that will contains users FCM-TOKENS per JID
Developing FCM on android devices and send TOKEN whent it refreshed to my WebService and save it in db.
Activate "CallBackOnOffline" plugin in openfire. (that sends POST request with a JSON to defined url when a message received but recipient is UnAvailable)
Set "plugin.callback_on_offline.url" in "Service Properties" to my WebService. So the message and the jid will be sent to my web service.
Now fetch the FCM-TOKEN from my web service db and send a request to FCM containing message body and title.
You can send push notification any time the user is online or not but the device has internet.You have all devices device tokens so when you send a message to a particular user, use his device token and send push notification.
I'm totally new to hybrid world so I have to ask first.
Can I send notifications through GCM without a server?
I mean, I'm building a SPA with AngularJS and Firebase, but my customer asked me to make a dashboard for Android, so every time an user makes an order, they (both dashboard administrators) receive a PUSH notification on their phone: "A new order has been created", and when they "tap", the application opens.
I've been reading something about /topic/ endpoint to notify both of them, but I think I still need a server to do it. Do I?
It would be great if I simply post a http query using something like AngularJS' $http service to tell GCM to send a notification for that topic/usergroup.
Is that possible? If so, any idea about how?
Thank you very much in advance!
Sending a downstream GCM message can be done "without a server". One option is to send an HTTP request to GCM containing the required fields. Topic Messaging is available with GCM which does make it easier to send downstream messages without a server. Your client apps can subscribe for messages from /topic/usergroup and then you can send an HTTP request with /topic/usergroup as your "to" value, and subscribed clients will get it.
Note that you will need to set up a Google Developer Console project to get the required API key.
Check here for more information on the structure of GCM HTTP downstream messages.
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
My app have a connection with a php Server where the data is saved so the app its like a chat the user send a message and the other can see and awnser my doubt is if I stay constantly request the server to update the messages its gonna affect the performance and what is the better way to do this?
The best way to do this is using Push Notifications, you don't need to maintain an open connection but receive a message from your server that it's telling you there is a new message. The received message is too short so maybe you will not be able to send the message from the Push Notification but you can tell the app that a new message is ready in your server.
To do this in PHP you can refer to this link and link2.
Another chance is to use sockets, I give you a link about This.
You can make requests in your app to ask php server if the new messege is there. It will be working.
The second way is to implement in your server and app Google Cloud Messaging . It is "wired" into device and can push messege into device.
When I change data value from one android device, I will send this data value to server.
Then this value should be changed on every android devices simultaneously.
I am trying to make synchronized data value. For this problem can I use GooglePushNotification?
Yes. You can use GCM to implement this. You can follow below algorithm.
There will be an application on each android device which will register to GCM and send the registration ID to Server.
Whenever any data is changed, Android app will send that data to server.
Server will keep data with itself and send GCM tickle to all registered devices.
Once Push notification is received, each android client will communicate with Server to get latest data.
Just in-case device misses the GCM tickle, you can retry fetching latest data from server on each Network toggle.
Refer: http://developer.android.com/google/gcm/index.html
Hope This Helps!