All of us enjoy, today, the benefits of notifications push and our applications. And, I do not know about you, but I never asked myself how these notifications would work until I had to study it in a subject of the career.
And, if I’m honest, the operation is so obvious that it would never have crossed my mind. Do you think we can see how push notifications work?
What are push notifications?
A push notification is basically a message sent by a server to a customer who is “subscribed” to your notifications. It is imperative that a server exists.
There are many types of system architectures; distinguishing two examples that are almost opposite, client-server architectures and P2P architectures. Push communications, as defined, only possible in client-server environments, in which one or many clients are subscribe to a specific topic of those offered by the server.
Push versus pull
We must distinguish, first, two terms: transactions push and transactions pull. There is a fundamental difference between the two, and it has to do with who initiates communication in architectures publisher-subscribe (that is, architectures in which clients are subscribe to updates from a publisher, to at least one of the topics they have available).
On transactions push it is the server who initiates the transaction. An example of this is when we have push mail, that is, when we are notified of new emails at the time of receiving them, and not after a periodic check by the client. It is the server that sends a message to the client to notify him that there are new e-mails.
On the contrary, in transactions pull the transaction is initiated by the customer. It would be the case that we perform a manual synchronization with our email server, instead of waiting for the message from the server. It would also be the case, for example, of simply visiting a web page.
How does the technology push?
Push technology, at the infrastructure level, can be implemented on practically all servers. How do these types of messages work? There are several options.
On one side, the server keeps the connection open, so that as soon as the server receives a certain event, it can send the corresponding information to the client. If the connection had been closed, the server would need to keep a queue to send the information as soon as the client reconnects.
This information can be sent, for example, through content formatted in HTML and a small script that is responsible for modifying an element of the page. Another example could be to send the information in JSON or XML format and have a script on the client who is in charge of interpreting it.
We must realize that we are always talking at a very high level: really, in this context, we do not care what type of packets are sent, what type of protocol is used to carry out communication and what type of network is underneath. It only matters that the message is sent, and that the message is received correctly.
What systems are push?
Some of the examples of technologies that make use of transactions push They may be:
- IMAP. Push notifications are not part of the original standard for IMAP, but are part of an extension described in RFC-2177, which describes the IDLE command, sent by the server to indicate to the client that there is new mail. Both the server and the client must have support for this command.
- Incidentally, the push mail BlackBerry, with the peculiarity at the time of being the first service that allowed push communications for mobile email.
- The vast majority of instant messaging systems, such as IRC or Messenger. These systems and protocols have support for push transactions. Improve performance when it comes to getting instant communication (or close to it): you don’t have to continually check for news. They also have file push support.
- The SMS they are a perfect example of a push message.
In addition, mobile platforms (iOS, Android) usually have a service of push notifications that developers can use to avoid the cost of developing their own server that sends push messages to users.
Image | Yutaka Tsutano | Cheon Fong Liew