Push notifications, push technology?



In web development. Thanks in advance!

In: Engineering

Hard to do it at eli5 but eli15 maybe.

You agree that app sends you notifications.
App sends your device information to push notification platform.

App has a promotion for example.
People or an automated task say to notification platform, send this group of users (e.g. who recently bought something) this notification.

Notification platform gets and does the task.

Every so often your phone/computer will refresh and scan through all your apps and emails in the background and see if anything has changed. If it has it will let you know.

Simplified analogy:

**Pull**: you go to the post office to collect your mail;
**Push**: the mailman comes to your house to deliver your mail.


In web development, a [HTTP request](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_message) (used for fetching a web page, or other data) is basically a one shot request, where no connection is held with the server^1. In other words, you request information when you need it (*pull*) and then the connection with the server is closed; the server cannot send you information without you explicitly requesting it first (*push*).

However, over the years different technologies have emerged which allowed servers to send you information at a time of its choosing (or make it appear as such).

For instance, nowadays you can use [*WebSocket*](https://en.wikipedia.org/wiki/WebSocket)s, which genuinely keeps a connection open with a server, allowing it to send data to the client, at a time of its choosing, so long as the connection remains open.

In earlier days there was [*(long-)polling*](https://en.wikipedia.org/wiki/Push_technology#Long_polling) (which by no means is an outdated technique), in which it appears as if the server sends data unsolicited, but in actuality the client is periodically making requests to the server in the background to poll whether new data is available.


Take reddit’s website for example (using a desktop web browser and reddit’s old design; not sure if this still applies to the new design):

When you request a reddit web page in your browser (*pull*), your browser shows you this page. Basically the connection with the server is then closed, until you refresh the page, request another page, or perhaps perform an action that requests data in the background while staying on the page.

However, you will, for instance, not be notified of new reddit personal mail (orange mail icon), *while* you are on said page. You will only be notified when you make a new request (refresh the page, or request different page).

If reddit *would* do this, that would be considered a push (notification).


1) For simplicity, I’m deliberately ignoring [Keep-Alive](https://en.wikipedia.org/wiki/HTTP_persistent_connection) here.