JSFiddle - React, Tailwind, and code Playground

by mkerny45

HTML

<button id="show_button">Test</button>

JavaScript

document.querySelector('#show_button').addEventListener('click', function() {
  if (window.webkitNotifications.checkPermission() == 0) { // 0 is PERMISSION_ALLOWED
    // function defined in step 2
    notification_test = window.webkitNotifications.createNotification(
      'icon.png', 'Notification Title', 'Notification content...');
    notification_test.ondisplay = function() { console.log('hi'); };
    notification_test.onclose = function() { console.log('hi'); };
    notification_test.show();
  } else {
    window.webkitNotifications.requestPermission();
  }
}, false);