Currently, I just re-open the notification when it closes, and when I explicitly close it (by clicking), I allow it to actually close.
// This assumes you already checked for permissions and have notifications working var MyNotify = function(message) { this.message = message; this.open(); }; MyNotify.prototype.open = function() { var self = this; // Notification is the native browser method self.instance = new Notification(self.message); self.instance.addEventListener('close', function(){ // We force firefox to continually respawn notifications until they explicitly close if (!self.shouldClose) self.open(); }); self.instance.addEventListener('click', function(){ self.close(); }); }; MyNotify.prototype.close = function() { self.shouldClose = true; self.instance.close(); }; new MyNotify('Hello World');
source share