Skip to content

Instantly share code, notes, and snippets.

@vldvel
Created March 14, 2018 07:51
Show Gist options
  • Save vldvel/286f9af45bd2fa3a686108ad96010b3c to your computer and use it in GitHub Desktop.
Save vldvel/286f9af45bd2fa3a686108ad96010b3c to your computer and use it in GitHub Desktop.
Notification request promise
Notification
.requestPermission()
.then((permission) => {
if (permission !== 'granted') throw new Error('No access!');
})
.then(() => {
console.log('We have an access!');
// Handle granted permission here
})
.catch((err) => {
console.log(err);
// Handle denied permission here
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment