'use strict';
+/*
+ Handle an incoming push notification
+*/
self.addEventListener("push", function(event) {
var data = {};
// Nothing
}
+ // Pass the data on for follow-up events
+ data.data = data;
+
// Log what we have received
console.debug("Push notification has been received: " + data);
// Close the notification
event.notification.close();
- event.waitUntil(
- clients.openWindow('https://developers.google.com/web/')
- );
+ const url = event.notification.data.url;
+
+ // Open the URL if any
+ if (url) {
+ event.waitUntil(
+ clients.openWindow(url)
+ );
+ }
});
// pushsubscriptionchange Handle this?