Created
April 3, 2012 15:49
-
-
Save tantalor/2293096 to your computer and use it in GitHub Desktop.
Mozilla Notification API
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
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}); | |
}; | |
} |
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
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