I created this:
// Nofitication Function
function myNotification(channelName, title) {
var notification = browser.notifications.create("id",{
"type": "basic",
"iconUrl": browser.extension.getURL("icons/64.png"),
"title": title,
"message": "Text",
"eventTime": 32400000
});
browser.notifications.onButtonClicked.addListener(function() {
// Do something when X (close) button got pressed?!
});
}
//------------------------------------------------------------------------------
Now I have some problems with it.
1. Problem: eventTime
The event time should keep the Notification alive for 9h.
I tested it with 1, 2, 5 minutes aswell. Wont work. It’s close after ~10-15 sec…
2. Problem: onButtonClicked
I try to get the X (close) button clicked (right top corner of a Notification).
When a user close the Notification with the X-Symbol, it ads a 9h rotation time.
So that the Notification will not apear again in the next 9h.
The same for a click ON the Notification. If someone click the Notification a new browser tab is opened.
And the delay is set to 9h aswell.
I tried the onClosed() method. But this happens also when the Notification disapears without any user interaction (click).
So I can’t use onClosed().
But onButtonClicked() seems only working with a custom button or something.
Here are the resources:
- Create: https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/notifications/create
- Event time: https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/notifications/NotificationOptions
- onButtonClicked: https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/notifications/onButtonClicked
- onClosed: https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/notifications/onClosed
I could use the onClosed() Method instead of onButtonClicked IF I can keep the Notification alive forever (eventTime).
Thanks for your help! <3