shadrack
shadrack

Reputation: 1

How to create real time notifications system in php and ajax

I wonder how social media websites pop up a notification for every action that happens on your timeline.

Am in need real-time notification system keeps track of every action you and your friends do on these social channels. Notifications form a big part of the real-time engagement feature of these platforms. Even you are not online, you could still receive these notifications.

Upvotes: 0

Views: 784

Answers (1)

Ian
Ian

Reputation: 461

There are a few ways to achieve this.

  • Long polling Make an HTTP request to the backend, the backend will then hold this request until there is a message that has to be sent to the client. (this is an older way but is still in use)
  • Push API Quite new, has pretty decent support. Find more info here: https://developer.mozilla.org/en-US/docs/Web/API/Push_API
  • Websockets Set up 2 way communication with the server. PHP is really bad at this imo and it's overkill if you're just trying to send notifications.

Both Long polling & Push API are a good solution these days depending on which browsers you need to support.

Upvotes: 1

Related Questions