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
+22k Golang : How to run Golang application such as web server in the background or as daemon?
+4.5k JavaScript : Rounding number to decimal formats to display currency
+18.2k Golang : How to remove certain lines from a file
+12.5k Golang : Get absolute path to binary for os.Exec function with exec.LookPath
+8.4k Golang : Add text to image and get OpenCV's X, Y co-ordinates example
+7.2k Golang : How to detect if a sentence ends with a punctuation?
+6.7k Swift : substringWithRange() function example
+14k Javascript : Prompt confirmation before exit
+12.1k Golang : Flush and close file created by os.Create and bufio.NewWriter example
+11.3k Golang : Format numbers to nearest thousands such as kilos millions billions and trillions
+17.5k Golang : Parse date string and convert to dd-mm-yyyy format
+19.5k Golang : Set or Add HTTP Request Headers