Last Updated: February 25, 2016
·
2.462K
· killme2008

Chrome notification

var notification = webkitNotifications.createNotification(
                'icon.png',
                'title',
                'text"
);
notification.show();
   //cancel it after 5 seconds.
setTimeout(function(){
    notification.cancel();
},5000);

In manifest.json:

"permissions": [
    "notifications"
 ],
"web_accessible_resources": [
   "icon.png"
 ]

2 Responses
Add your response

Worth saying that this could also be used in webpages, you'll need to add permission handling with: window.webkitNotifications.checkPermission() and window.webkitNotifications.requestPermission().

Note: You must try this using a server request (it won't work with a file:// URL )

A complete example can be found here: http://www.html5rocks.com/en/tutorials/notifications/quick/

regards!

over 1 year ago ·

Yes,i've read your post before,thanks.

over 1 year ago ·