I am looking to implement notifications on my app. The way I would like for this to work is when I put something on my website, that is connected to my app, it gives a notification automatically even if the app is not running. I am just looking for the easiest way to accomplish this. By the way the info that is added from the website is put into a listview in the app(if that helps at all).
The server needs to do a several things in order to talk GCM:
http://developer.android.com/google/gcm/http.html
The client needs to do some registration and let your server know of the GCM registration ID:
http://developer.android.com/google/gcm/client.html
Those links will provide much more detail though
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
Your app may poll your side every N minutes/hours/days or you can use Google Cloud Messaging service.
GCM: Here is a link describing the usage of GCM with a PHP web server:
http://www.programming-techniques.com/2014/01/google-cloud-messaging-gcm-in-android.html
So if you have any update on your site this can notify GCM which will notify all registered users (their devices with your app running).
Related
I have set up push notification from Firebase console and I can send push notifications. However, I cannot send device-to-device notification yet. As I gather I would need an external app server that would observe Firebase nodes for change and then would fire off a notification via FCM.
I have seen similar question in SO here and a good but brief and not so complete explanation by Frank van Puffelen here. But I am still quite confused. Any tutorial or help as to how I can set up an app server (XMPP here) that would do the communication between client app instances and Firebase for sending notification when ChildAdded or modified and handling the key exchanges would be appreciated. (as I understand, FCM needs XMPP protocol for sending upstream notification)
Any help would be appreciated.
Following this tutorial.
Send Notifications from Server
What you can do is, setup an external server using your favorite technology to listen child_added or changed and respond to the notification requests.
We used the node.js app engine to handle this. Again the funda is to move people to use other cloud paid services.
Yours it's a good question... The firebase can't send push device-to-device, then if you want to do this one, needs a app server as you said. The other possibility that I thought for a long time is a create a independent service to do two things, the first one is constantly controls events as onChildAdded, for exemple and the second one, throws local notifications.
This is solution that i think works fine before to create a app server... At final if you try to do it, explain us your experience please! Greetings!
Probably a GCM newbie question...
I more or less understand how to subscribe to topics and how to send messages to topics. But I was wondering : how does a topic gets created ?
From the docs I read, I guess a topic exists when at least one app subscribes to it, correct ? (As far as I could see there's no specific api to 'create' a topic).
I also noticed that it should be possible to register apps to a topic not from the app itself, but from an app server (by sending a HTTP POST message to a specific URL). Does this work the same way ?
E.g. if the topic doesn't exist when subscribing, it will be 'created'?
As far as I can tell, yes, whatever topic name a client app uses when subscribing, will get created. Even if it is "sdfgklfhjashfgkjas" and purely accidental.
I have seen no mention of deleting topics. I guess unused topics don't really cause Google any problems; they don't take up much space.
On the server side, you can force an app instance to subscribe to a topic by passing the token in a http POST as mentioned in the GCM documentation. Ditto for unsubscribing from a topic.
Bear in mind there are limits on topics which could cause problems for popular apps.
How does a topic gets created?
There is no detailed explanation in the documentation on how topics are created but according to the documentation.
An app can subscribe to different topics defined by the developer. The app server can then send messages to the subscribed devices without having to maintain topic-subscribers mapping. Topics do not need to be explicitly created before subscribing or publishing—they are automatically created when publishing or subscribing.
From the docs I read, I guess a topic exists when at least one app subscribes to it, correct ?
I think this is the case because in order to create a topic you will have an app subscribe to it.
I also noticed that it should be possible to register apps to a topic not from the app itself, but from an app server (by sending a HTTP POST message to a specific URL). Does this work the same way?
Yes your app can subscribe to other topics not necessarily related to your app as long as you pass the GCM registration token and topic name. See Subscribe to a topic.
I am developing an app in android in Eclipse IDE. The app modality requires that any user can challenge his/her friend to do a certain activity. Whenever a user does so, the friend will immediately get a notification in his/her phone. Even more, the user who challenged the friend, will also receive a notification when the friend accepts the challenge. Is there any particular way I can provide this functionality? I know how to generate notifications. But the server side interaction is quite confusing. Should I check the server database through the app at frequent intervals and check for such activities in database? I think the procedure will hamper the performance of the app. I would be very grateful if anyone can suggest a good way.
But the server side interaction is quite confusing.
As you're pointing out, it's the server part not the Android one what's confusing here. If you don't have any constraints on the server part, I'd recomend to use Socket.io http://socket.io/ They have a tutorial for connecting socket.io with Android: http://socket.io/blog/native-socket-io-and-android/
It seems that you don't really need an interaction between the differents users but only a way to notify them. I always used Google Cloud Messaging to do so. It enables you to receive push notifications. As you said, checking the server periodically is battery/data consuming and not the best way to do it.
This link might help to set up GCM : http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/.
I have an android application where push notifications are implemented by GCM.
I need to change this. I need that with the new release (the app is already in the Store and people already use push with GCM) all the mechanism will be handle from Parse.
Can I simply delete everything concerning GCM and implement everything concerning PARSE and then upload the version of the application and be sure that everything will run the same?
Has anybody an idea if there will be conflicts with doing this? I'm thinking about devices that already have a GCM token for example.
You should try it and see. I think when implementing Parse, the registration ID (unique to every app <--> device) will be generated again. I've written a couple of articles on the topic which are not directly useful but can help in other ways.
Just make sure you follow this thoroughly.
I am a newbie in android. I have developed few applications, but all are plain and simple, just used the built in features of android.
I was asked about push notifications, in one of my interviews and I decided to have a look at what Push Notifications are. I understand the concept of Push Notifications(I think), but whenever I read the term "Server", it's freaking me out.
I understand all the client side coding, but I don't get how to implement the server side coding. I have seen some people use XMPP, MQTT, etc., What are those? Here is my scenario and what I want to know..
Scenario ::: Let's say I have a website, with a table (the values are retrieved from database), where I update a few columns every day. I want these updates to be reflected in my android application. So, as I have read, push notifications can tell the application that there are updates available. Good. I am fine till here..
When the application gets the notification, should my application, contact the website and get the latest information? or will the updated information sent through Push Notification? I guess, my application would be contacting the website and get the information. Now, how do I get the data from the website? Should I get the source of the page and do some kind of parsing or something?
I will be asking more questions, as the experts clear my questions...
Sorry, if my questions are too naive, but this is the only place that can help me...
Push Notifications means Google Cloud Messaging for Android (GCM) is a service that allows you to send data from your server to your users' Android-powered device.
You can refer to this documentation
Google Cloud Messaging for Android
GCM: Getting Started
And there is also Demo App Tutorial given
in your case you need to create HTTP web service for getting data from the server.so when you get notification about update on server side.you just need to call this web service and get the data you need to update