Unable To Show Desktop Notifications Using Google Chrome
I followed the instructions as given in Using The Notifications API. Also I faced many problems like the below, because I added the document.querySelector() inside the
Solution 1:
After creating the notification, you need to call show()
on it, so instead of just:
createNotificationInstance({ notificationType: 'simple' });
you need to do:
var n = createNotificationInstance({ notificationType: 'simple' });
n.show();
The other thing is: when doing jQuery code, wrap it inside
$(document).ready(function() {
// ...// your jQuery code// ...
});
When doing actions on the DOM with jQuery inside the head, the DOM isn't build yet. $(document).ready
waits until the DOM is build and you can savely access and manipulate it.
Here is a working example: http://jsfiddle.net/fkMA4/
BTW: I think HTML notifications are deprecated, see here: http://www.html5rocks.com/en/tutorials/notifications/quick/?redirect_from_locale=de
Notifications with HTML content have been deprecated. Samples and text have been modified accordingly.
Post a Comment for "Unable To Show Desktop Notifications Using Google Chrome"