Reputation: 1740
For those of you wanting to just cut to the chase and know what im asking. My questions are numbered and bold-ed in the paragraph below.
Im having a heck of a time trying to figure out 1.)how to implement a proper notification system for a Android social networking app? So far all ive gathered is that there are 2 choices, polling vs. pushing , pushing is better than polling bc it conserves battery and the recommended way of pushing notifications is through the Google Cloud Messaging(GCM) , but what I dont get is 2.)what makes my server push? and/or 3.)how to setup my server side to push when there is new data available? Further research has hinted that Facebook is only able to achieve their nearly real-time notification system bc they have some sort of server side api/library/technology called thrift or something like that that detects whos online and who isnt (not positive why this matters yet) . 4.)Is there anyone with some tips for me who has tried to implement a social notification system similar to Facebook ?
Other important info:
Im currently using a Codeigniter Rest server for a api(PHP)
I would prefer php solutions that I can implement using my existing API UNLESS there is a solution in another language(Java,Ruby, Javascript) that can be implemented independently( aka I can still use my existing api for everything else besides notifications)
I am not looking for someone to explain how to use GCM or direct me to a tutorial. I have done research and gotten several "examples" of GCM push notifications up and running , but none of the tutorials ive found so far show me how i can make my server push on its own.
The types of notifications I need to make to users are things like new friend requests, new private messages from other users , new comments on content posted by the user being notified , new comments on content the user has commented on ( similar to how fb notify's you if a comment is added to a status uve commented on)
Upvotes: 3
Views: 2519
Reputation: 3090
For the tasks you described (friend requests, private messages, notifications, etc), GCM is definitely the way to go. Your server will send the GCM message when the event occurs, and Google manages the sending of the message - you do not have to worry about the phone being on or anything like that.
It sounds like you're close to getting this all put together, but there is one part that is missing - the actual sending of the GCM message. There is no notion of an auto-push, at least in my experience. Each push is based off of some action occurring, like a message being sent or a new friend request. For example, if you already have code set up to handle a friend request on your server and update your database, you would just need to add a bit of code to look up the GCM ID for the requestee and send a GCM message telling your client that a friend request has been received. On the Android client side, you would have a class that extends GCMBaseIntentService that would receive this message and run whatever client side code you want to run when a friend request is received (post a local notification, update a ui, etc.)
Upvotes: 5