I have a extension that shows a notifications, and worked fine until chrome updating and doesn't work any more with Chrome.
What I should edit on this code to make it working. here is my code.
deskNoti=webkitNotifications.createNotification(chrome.app.getDetails().name,'You have '+counter+' new messages');
deskNoti.onclick=function(){openPage();this.cancel()
};
deskNoti.show();
if(timeNoti){window.setTimeout(function(){deskNoti.cancel();},timeNoti);}
webkitNotifications
has been removed. The direct replacement is Notifications API.
The code is easy to translate:
// Instead of calling a create function, one calls the "new" operator:
deskNoti = new Notification(
chrome.app.getDetails().name,
// Instead of just message text, the second parameter is now an object
// with multiple properties. Message text should go into "body" parameter:
{ body: 'You have '+counter+' new messages' }
);
// Instead of .cancel(), the function to close the notification is now .close()
deskNoti.onclick = function() { openPage(); this.close() };
// Notifications are now shown automatically; there is no .show() function
//deskNoti.show();
if(timeNoti) {
window.setTimeout(function() { deskNoti.close(); }, timeNoti);
}
Consider using chrome.notifications
API instead.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments