Created
February 21, 2020 14:25
-
-
Save novaknole/5594c3603257cbd62dd3e377548a9ec1 to your computer and use it in GitHub Desktop.
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
function askPermission() { | |
return new Promise(function(resolve, reject) { | |
const permissionResult = Notification.requestPermission(function(result) { | |
resolve(result); | |
}); | |
if (permissionResult) { | |
permissionResult.then(resolve, reject); | |
} | |
}) | |
.then(function(permissionResult) { | |
if (permissionResult !== 'granted') { | |
throw new Error('We weren\'t granted permission.'); | |
} | |
}); | |
} | |
askPermission().then(d => { | |
navigator.serviceWorker.ready | |
.then(function(swreg) { | |
console.log("blaxblux"); | |
swreg.showNotification('Successfully subscribed!', {body:'giorgi'}); | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment