webkitnotifications doesn't work in Chrome

Alex

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);}

Xan

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

AddFavorite JS doesn't work with chrome

From Dev

Chrome debugger doesn't work on typescript files

From Dev

Position Fixed doesn't work in Chrome

From Dev

Cookies permission in Chrome extension doesn't work

From Dev

Chrome - focus on input doesn't work

From Dev

My JavaScript doesn't work with chrome

From Dev

EditDocument doesn't always work in Chrome

From Dev

download attribute on <a> tag doesn't work in Chrome

From Dev

Jqgrid default sorting doesn't work in Chrome

From Dev

jQuery contains doesn't work on Chrome

From Dev

Gwt plugin doesn't work in Chrome 42

From Dev

onclick method doesn't work in Chrome

From Dev

Location is accessed in Chrome, doesn't work in WebView

From Dev

Selenium (Chrome) and BrowserMob doesn't work for https

From Dev

Position Fixed doesn't work in Chrome

From Dev

Disqus authentication doesn't work in Chrome

From Dev

Set cookie in ApiController doesn't work in chrome

From Dev

Ajax Doesn't work in Chrome,Firefox, & Opera

From Dev

WebRTC - enable sound in chrome doesn't work

From Dev

jQuery click doesn't work on chrome

From Dev

download attribute on <a> tag doesn't work in Chrome

From Dev

My JavaScript doesn't work with chrome

From Dev

If statement doesn't work - chrome extension

From Dev

jQuery show function doesn't work on chrome

From Dev

Jqgrid default sorting doesn't work in Chrome

From Dev

OnClick event doesn't work in Chrome

From Dev

onclick method doesn't work in Chrome

From Dev

Anchor doesn't work in chrome and safari browsers

From Dev

Subresource Integrity Protection doesn't work in Chrome