This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<!-- View this at https://rawgit.com/anitawoodruff/b41cad489dba75cdbaf2ea942450cd1f/raw/ --> | |
<meta name=viewport content="initial-scale=1"> | |
<a href="https://gist.github.com/anitawoodruff/b41cad489dba75cdbaf2ea942450cd1f">View code</a><br><br> | |
<button id="myButton">Show notification</button> | |
<script> | |
navigator.serviceWorker.register('sw.js'); | |
document.getElementById('myButton').addEventListener('click', event => { | |
navigator.serviceWorker.ready.then(swRegistration => { | |
Notification.requestPermission(permission => { |