Playing with Service Workers

Published on Monday, December 18, 2017

Service workers, Push API, Notifcations API and PWAs

This will not work for you as service workers are not supported

Location of the serviceworker.js file and scope matters

I started with the sw.js file in the assets/scripts folder with the rest of the script files, but calls to navigator.serviceWorker.getRegistration() were never returning, this stackoverflow thread explains the issue. Service Worker is never ready.

Maybe this is the proper way

{
    navigator.serviceWorker.register('/sw.js', {
    scope: './'
  }

Subscribe to notifications





Building Progressive Web Apps with Chris Love

Great explaination of Service Workers and further reading and offer for Chris' course on this episode of DotNetRocks.

PWA Builder

CORS

As the blog is a static site and the backend is hosted in azure it is neccessary setup CORS using one of the examples hereEnabling Cross-Origin Requests (CORS)

don't forget to do the CORS section in Azure if you are using that.