Skip to content

Instantly share code, notes, and snippets.

@adamterlson
Created September 11, 2013 16:11
Show Gist options
  • Save adamterlson/6525873 to your computer and use it in GitHub Desktop.
Save adamterlson/6525873 to your computer and use it in GitHub Desktop.
Shim Notification API in chrome to expose permissions
function translateWebkitPermission(code) {
switch (code) {
case 0:
return 'granted';
case 1:
return 'default';
case 2:
return 'denied';
}
}
if (!Notification.permission) {
Object.defineProperty(Notification, "permission", {
get: function() {
return webkitNotifications && translateWebkitPermission(webkitNotifications.checkPermission());
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment