Created
January 31, 2012 17:19
-
-
Save joshbirk/1711686 to your computer and use it in GitHub Desktop.
Using Streaming API w/ jQuery And Notifications
This file contains 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
j$ = jQuery.noConflict(); | |
j$(document).ready(function() { | |
j$.cometd.configure({ | |
url:'https://'+window.location.hostname+'/cometd/23.0', | |
requestHeaders: {"Authorization": "OAuth {!$Api.Session_ID}"} | |
}); | |
j$.cometd.init(); | |
j$.cometd.subscribe('/topic/AllDogs', function(message) { | |
console.log(message); | |
flashObject.handleDogData(message.data.sobject,message.data.event.type); | |
console.log(window.webkitNotifications.checkPermission()); | |
if (window.webkitNotifications.checkPermission() != 0){return;} | |
console.log(message.data.sobject.Name + 'has has been '+message.data.event.type) | |
window.webkitNotifications.createNotification('http://www.salesforce.com/favicon.ico', message.data.sobject.Name, 'has has been '+message.data.event.type).show(); | |
}); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment