Notification API

<button class="notify">Notify Me</button>

<script>
  $(".notify").click(function () {
    notify();
  })

  function notify() {
    (async () => {
      // create and show the notification
      const showNotification = () => {

        // create a new notification
        const notification = new Notification('Title', {
          body: 'Description',
          icon: 'ImagePath'
        });

        // close the notification after 10 seconds
        setTimeout(() => {
          notification.close();
        }, 10 * 1000);

        // navigate to a URL when clicked
        notification.addEventListener('click', () => {
          //Do something after click the notification
        })
      }

      // show an error message
      const showError = () => {
        //Do something if error
      }

      // check notification permission
      let granted = false;

      if (Notification.permission === 'granted') {
        granted = true;
      } 
      else if (Notification.permission !== 'denied') {
        let permission = await Notification.requestPermission();
        granted = qwe === 'granted' ? true : false; 
      }

      // show notification or error
      granted ? showNotification() : showError();
    })();
  }
</script>