Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Push Notification In Mobile Web

Is it possible to receive notification on mobile devices whenever it's generated from the web Server.

This thing can be achieved by native apps for iPhone and Android. But my requirement is to achieve the same via a mobile website. Also is it possible to receive notification even if the user has closed the web browser.

like image 649
Tanmay Mandal Avatar asked Oct 23 '22 02:10

Tanmay Mandal


1 Answers

It is possible to acheive, and you have 2 main ways to achieve this:

  1. WebSockets (HTML 5 required)
  2. HTTP long polling

Both methods require some trick server software, a good example is Socket.IO running on Node.JS platform.

Websockets require an HTML 5 browser (eg, Chrome) so might not work for your requirements.

HTTP long polling is the act of accepting an inbound HTTP connection on the server, and then sleeping until you wish to push the data to the client. Node.JS can be set to do this quite easily, or you could use Socket.IO (a library on Node.JS) which provides extra functionality. Socket.IO also works with Websockets where possible - and falls back to long polling if it has to.

In short, you will need a server platform to do this - I suggest you look at Socket.IO to start with. You can always roll your own once you have the main concept nailed. I wrote one in ASP.net which worked quite well, for example.

like image 185
justacodemonkey Avatar answered Nov 15 '22 05:11

justacodemonkey