Created
February 28, 2018 14:51
-
-
Save zlatkov/54535c87cfda64986d554d256021e0ad to your computer and use it in GitHub Desktop.
This file contains hidden or 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 requestPermission() { | |
return new Promise(function(resolve, reject) { | |
const permissionResult = Notification.requestPermission(function(result) { | |
// Handling deprecated version with callback. | |
resolve(result); | |
}); | |
if (permissionResult) { | |
permissionResult.then(resolve, reject); | |
} | |
}) | |
.then(function(permissionResult) { | |
if (permissionResult !== 'granted') { | |
throw new Error('Permission not granted.'); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment