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

rewrite asp to php based on asp query -

android - questions about switching from C2DM to GCM -

visual studio 2010 - Error on RDLC Expression -