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.
Related
I have two version from my app one for the customer and one for the client I need to send push notification to the specific client(in client app) when the customer take an specific action (in customer app).
I know that I should use Firebase Cloud Messaging as it's a new replacement to GCM, but I can't figure out how I can do this in both server side and client side.
you have a lot of options here!
let's start with the server side:
you have two options HTTP or XMPP, HTTP is a one way connection XMPP is two way.
for your app you will need XMPP for upstream and down stream messages
check there Guides it's really great: Server guide
there is also a Java and Node.JS Admin SDKs but i don't know much about.
but there is a great Tutorial which describes the whole proccess if you go for Node.js
So what happens is:
when a device sends an upstream message
Firebase will forward it to your server
Your server should handle the message and send it to the other device through Firebase cloud messaging
you can implement a server-less app using real time databse but you will not receive message in background, but when the receiver app is running it listen to databse changes and send notification to user
you can also make a server listens to databse changes "instead of receiver" and take actions upon it"send a message to the other device"
Edit:
with the new cloud function feature you can now use it to send notifications to users based on database events,
so you can add your message to database in a class
and make a cloud function to listen to this class write events
and whenever a message saved to this class, it sends it to desired
receiver
so now you don't need an external server to send notifications to
devices
check this cloud function sample, it's an example of sending notifications based on database event.
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.
I'm very new in meteor and I just made a simple app that show news (text) for a school, the problem is that no one knows when they write something new because the app doesn't have notification. I can't figure out how to use raix:push or richsilv:cordova-notifications because the test of raix:push didn't work in my device (android) and richsilv:cordova-notifications just work with android and I couldn't make it automatic. Saying "automatic" I mean "when the mongo collection is updated a notification is sent"
I think you may need to set up push server for sending notification to Android client.
Google is providing such option, where client app has to register with GCM server. On successful registration, google will give reg Id, which has to be stored in DB.
From your server make HTTP request to GCM server with Reg Id and message. GCM will deliver the message to appropriate device.
Please refer https://developers.google.com/cloud-messaging/gcm
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 make app in android in which i wand to send some message to server and also want to get notification from server if there is any updates via C2DM in android.
How to send message to the third party server. (Third-party server like php)and inputs are necessary to send message to the third-party server. and how to send response Third-party server to C2DM and get notification from C2DM to Android device?
Well that's like asking "How do I write an Android application?" and expect to get a full answer.
I suggest you start with reading this:
http://code.google.com/intl/sv-SE/android/c2dm/index.html
Then download the Chrome To Phone source code see how they implement the C2DM solution. It is fairly complicated but if you know how to make http POSTs from your Android application and your server you will succeed.