3

Community:

ServiceWorker is a great advance technology in terms of cache managment, but I have some questions associated with other operations such as:

Push Notification: I made a GCM integration (Google Clud Message) and NodeJS, following this article, the problem is that when GCM sends the information to the client (Chorme), the payload of the message generated by GCM is not accessible in the Notification in ServiceWorker Listener, which would be great for making decisions. Any Idea when data payload in notifications will be enabled?

Registration: Since ES6 is very mature, it would be good to register a ServiceWorker in other ways, for example:

import sw from './sw.js'

navigator.serviceWorker.register(sw, {scope: '/'}).then(function (registration) {
 // Registration was successful
 console.log('ServiceWorker registration successful with scope: ', registration.scope);
}).catch(function (err) {
 // registration failed :(
 console.log('ServiceWorker registration failed: ', err);
});

Is this possible or make sense?

Thanks!!!!

Cristian Rinaldi
  • 329
  • 4
  • 15
  • Your registration example code isn't really possible, because what you are supposed to be passing to `.register` is a whole new file to load in a brand new JS environment. The code you have posted would execute the service worker inside the page's JS environment, then try to pass some reference to it. – loganfsmyth Jun 17 '15 at 14:39

1 Answers1

2
  1. The "Support encrypted payloads for push messages" bug tracks progress on getting payloads exposed in notifications. That bug is Chrome-specific, but other browser vendors are likely to follow the same approach.
  2. The service worker upgrade flow is very much tied to the idea of there being a specific JavaScript file which represents the service worker's code, and that file can then be periodically checked, byte-by-byte, to see if there are any updates. If it were an in-memory JavaScript object that was registered, detached from the file, the upgrade flow wouldn't work as specified. I don't think you'll see the change you're proposing added to the specification.
Jeff Posnick
  • 53,580
  • 14
  • 141
  • 167
  • Thanks for answering @Jeff Posnick On point 1, nothing to say, the answer is very clear ... Abount to point 2, would be great to have the flexibility to run on another thread more things a script, for example the instance of an imported service (class) of the current thread. All this is to make better use of the system of import and export of SS6. – Cristian Rinaldi Jun 18 '15 at 14:45