Search code examples
javascriptjavaweb-applicationspush-notificationweb-notifications

How to send push notifications to web application and browser?


I have a database in which I insert and send data using java.So I want to send push notifications using java to my web application and getting them in javascript.

I also want to send push notification to my browser.Is there an easy way to do these two things? I have been trying for days but I have not found a well explained tutorial that I can understand.

Thank you in advance.


Solution

  • It sounds like you may want to try websockets which any modern browser will support.

    Effectively, it opens a TCP channel between the browser (javascript) and the server. Messages can be written to the socket and received and handled by the browser.

    An old but good introduction is: https://www.html5rocks.com/en/tutorials/websockets/basics/

    The only other alternative would be to perform either polling at various intervals using javascript, or long polling. Both have issues, particularly at high volume. Websockets make more efficient use of network.