function setNotificationCallback(createCallback, clickCallback) {
  const OldNotify = window.Notification;
  const newNotify = (title, opt) => {
    createCallback(title, opt);
    const instance = new OldNotify(title, opt);
    instance.addEventListener('click', clickCallback);
    return instance;
  };
  newNotify.requestPermission = OldNotify.requestPermission.bind(OldNotify);
  Object.defineProperty(newNotify, 'permission', {
    get: () => OldNotify.permission,
  });

  window.Notification = newNotify;
}
function setNotificationCallback(createCallback, clickCallback) {
  const OldNotify = window.Notification;
  const newNotify = (title, opt) => {
    createCallback(title, opt);
    const instance = new OldNotify(title, opt);
    instance.addEventListener('click', clickCallback);
    return instance;
  };
  newNotify.requestPermission = OldNotify.requestPermission.bind(OldNotify);
  Object.defineProperty(newNotify, 'permission', {
    get: () => OldNotify.permission,
  });

  window.Notification = newNotify;
}
function setNotificationCallback ( createCallback , clickCallback ) { const OldNotify = window . Notification ; const newNotify = ( title , opt ) => { createCallback ( title , opt ) ; const instance = new OldNotify ( title , opt ) ; instance . addEventListener ( 'click' , clickCallback ) ; return instance ; } ; newNotify . requestPermission = OldNotify . requestPermission . bind ( OldNotify ) ; Object . defineProperty ( newNotify , 'permission' , { get : ( ) => OldNotify . permission , } ) ; window . Notification = newNotify ; }
Patches window.Notification to:
- set a callback on a new Notification
- set a callback for clicks on notifications
@param createCallback
@param clickCallback
Patches window . Notification to : - set a callback on a new Notification - set a callback for clicks on notifications
Sets a callback function to be called when the user clicks on a notification.