Javascript : Push notifications to browser with Push.js
Problem:
Instead of RSS, you want to send notifications to your visitor's computer through their browser about the latest updates that your blog or organization has to offer. Such as:
How to do that?
Solution:
Instead of implementing the notification with API, use Push.js instead. It is a free notification library that handles all the basic push notifications with a couple of JavaScript lines.
You can invoke Push.js with
<script>
Push.create('Hello! Thank you for allowing to push notification. I will be updating you with the latest updates')
</script>
To see more advanced configurations, head over to https://github.com/Nickersoft/push.js to see the available options.
In case you pressed the "BLOCK" button and unable to see the prompt again during testing phase, you will need to revoke the block/allow
notifications in your browser.
To do this for example, in Chrome - click settings
, scroll down to Advanced
tab, click Content Settings
and click Notifications
OR paste this chrome://settings/content/notifications
into the address bar.
NOTE: From my own experience, Push notifications will not be able to work with localhost.
See also : Javascript : Put image into Chrome browser's console
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+11.4k Golang : "https://" not allowed in import path
+16.5k Golang : Read data from config file and assign to variables
+8.4k Golang : How to protect your source code from client, hosting company or hacker?
+23.1k Golang : Time slice or date sort and reverse sort example
+5.8k Restart Apache or Nginx web server without password prompt
+5.9k Golang : Decode XML data from RSS feed
+6.2k Golang : Example of custom handler for Gorilla's Path usage.
+5.6k Golang : How to setup a disk space used monitoring service with Telegram bot
+20.5k Golang : Join arrays or slices example
+8.7k Golang : Identifying Golang HTTP client request
+12.8k How to automatically restart your crashed Golang server
+14.8k Golang : Generate universally unique identifier(UUID) example