Skip to content

Instantly share code, notes, and snippets.

@tantalor
Created April 3, 2012 15:49
Show Gist options
  • Save tantalor/2293096 to your computer and use it in GitHub Desktop.
Save tantalor/2293096 to your computer and use it in GitHub Desktop.
Mozilla Notification API
var notification = navigator.mozNotification;
if (notification && notification.requestRemotePermission) {
// Ask the user to allow notifications.
var request = notification.requestRemotePermission();
request.onsuccess = function() {
var url = request.result;
console.log('New push URL: ' + url);
// We got a new push URL, store it on the server.
jQuery.post('/push-urls/', {url: url});
};
}
var notification = navigator.mozNotification;
if (notification && notification.requestRemotePermission) {
// Ask the user to allow notifications.
notification.requestRemotePermission(function (result) {
var url = result.url;
console.log('New push URL: ' + url);
// We got a new push URL, store it on the server.
jQuery.post('/push-urls/', {url: url});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment