Skip to content

Instantly share code, notes, and snippets.

@Spyna
Created August 26, 2019 15:39
Show Gist options
  • Save Spyna/a92f163c9ff10ce9f416262cb29524bf to your computer and use it in GitHub Desktop.
Save Spyna/a92f163c9ff10ce9f416262cb29524bf to your computer and use it in GitHub Desktop.
How to open a web push notification
function openPushNotification(event) {
console.log("[Service Worker] Notification click Received.", event.notification.data);
event.notification.close();
event.waitUntil(clients.openWindow(event.notification.data));
}
self.addEventListener("notificationclick", openPushNotification);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment