javascript - Event Listener for Web Notification -


is there way set event listener desktop notification?

document.addeventlistener("desktop notification", function(){     // }); 

i've looked through mdn event reference, event type notification seems alert().

see https://github.com/jiahaog/nativefier project working sample. notice snippet (source https://github.com/jiahaog/nativefier/blob/development/app/src/static/preload.js):

function setnotificationcallback(callback) {      const oldnotify = window.notification;     const newnotify = (title, opt) => {         callback(title, opt);         return new oldnotify(title, opt);     };     newnotify.requestpermission = oldnotify.requestpermission.bind(oldnotify);     object.defineproperty(newnotify, 'permission', {         get: () => {             return oldnotify.permission;         }     });      window.notification = newnotify; } 

so, replace window's notification object own object act proxy added behaviour (calling callback on creating new notification).

hope helps


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -