Links: https://developer.chrome.com/apps/notifications
I use chrome.notifications.create (line identifier, object parameters, function callback); to create a chrome notification.
var id = 'list';
var options = {};
options.title = 'test';
options.iconUrl = 'notification_icon.png';
options.type = 'list';
options.message = "test";
options.buttons = [{title: 'test'}];
options.items = [{title: 'test', message:'test'}];
var createCallback = function(notificationId) { console.log(notificationId); };
chrome.notifications.create(id, options, createCallback);
This creates a notification as expected. Everything is working correctly.
Then I call chrome.notification.clear (string id, function callback);
var id = 'list';
var clearCallback= function(wasCleared) { console.log(wasCleared); };
chrome.notification.clear(id, clearCallback);
This clears the notification. Everything is working correctly.
EXCEPT does not clear the notification if the notification panel is open. This is not a serious problem in 99% of cases. Until I implemented the button code in the notification.
chrome.notifications.onButtonClicked.addListener( ); , , .
var onButtonClickedCallback = function (notificationId, buttonIndex) {
console.log(notificationId, buttonIndex);
if ( notificationId == 'list' ) {
chrome.notification.clear(id, clearCallback);
}
}
chrome.notifications.onButtonClicked.addListener(onButtonClickedCallback);
. , , . , , , , , .
persistence: false ( script, , , ).
- ? , . , , , .
Chrome 37.0.2019.0 canary Win8
- -, , , , . Google , HTML.