Home Ask Login Register

Developers Planet

Your answer is one click away!

De Santa February 2016

How to display push notifications from my website?

I'm developing a simple website and I want my website to display push notifications to my users. It is something similar to how facebook.com displays notifications in chrome and firefox. I'm also working on an Android app that also supports push notifications through GCM.

So I need help on how to add push notification support to my website. Thanks in advance!


PingCrosby February 2016

Would this help https://z-push.org/

You never mentioned which technology your developing you site in !

gerardnimo February 2016

You can use Service Workers in order to display notifications from a website as stated in Implementing GCM Client on Chrome. You can refer to push messaging codelab on how to implement it.

collimarco March 2016

Both Firefox and Chrome support the Push API.

Currently Firefox adhere to the standard, while Chrome uses an hybrid solution (Push API + GCM).

Basically you have to:

  • collect the endpoint (device token) and register a service worker (a snippet of code that will be executed later) using Javascript and the Push API
  • store the endpoint to the server
  • when something happens, from your backend you send the notifications to the browser manufacturer's service
  • the browser manufacturer's service delivers the notification to the browser (which has a permanent connection to it)

You can read this tutorial for Chrome and the Push API reference by MDN.

If you prefer a third party service I suggest the one I have developed: https://pushpad.xyz

Post Status

Asked in February 2016
Viewed 1,608 times
Voted 13
Answered 3 times


Leave an answer

Quote of the day: live life