Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build realtime push notification feature like facebook does? [closed]

I'm going to build realtime push notification feature for my web application ( a small social network) and I don't know where to start.

This is what I want to build: there are like buttons, comment forms, ... Users click like, write their comments and (relatively) immediately, on the owner's browser shows the number of new likes and comments, ... Something like that.

I've read about socketIo on nodeJs, MeteorJS but unfortunately, they need WebSocket supported by mordern browsers. I've just read about Comet technic and find it pretty easy to apply. But i'm not sure it will performs well because Comet relies on long-polling connection (correct me if I'm wrong).

In addition, I think facebook is using Comet for its push notification feature. Through console tab on firebug plugin I can see there's alway a holding connection to facebook. So can anybody show me a technic, a model to develop a feature like that?

like image 338
Hieu Pham Avatar asked Sep 21 '12 17:09

Hieu Pham


People also ask

Are push notifications real time?

Real-Time Notifications (RTN) are server-to-server push notifications that provide comprehensive data about in-app purchases in real time. You can use this information to monitor purchase state changes associated with your customer's in-app purchasable items.

Does Facebook use push notifications?

When you've downloaded the Facebook app, we may send you two types of mobile notifications: Push notifications: sent when you're not actively using Facebook (example: on your device's lockscreen). In-app notifications: sent when you're using Facebook.


1 Answers

A promising idea is to work with the HTML5 notification API; it's perfect if you want notifications to pop on the user screen as long as his browser is running (even if you're surfing another website or if all windows are closed).

http://www.paulund.co.uk/html5-notifications

However, if what you want is to update different parts of your page asynchronously (without refreshing or pushing a button), you should use together :

  • Ajax calls;
  • Listeners and observers.

When you Ajax calls retrieve particular types of json data (for example), it can trigger appearance of a badge (listener) with a number of new notifications, or so...

With JQuery installed, you should be fine...

Even though it's often not the case, sometimes, for simple tweaks, it's easier to code the job done...

You can start here :

How implement a "observer" in Jquery without plugins? (it's old, but interesting)

Or see this page :

browser instant updates with ajax/jquery

(incredible how often google queries return stacko' pages)

like image 185
Bruce BENAMRAN Avatar answered Sep 24 '22 17:09

Bruce BENAMRAN