DEV Community

Discussion on: Transform any Meteor App into a PWA

Collapse
 
jankapunkt profile image
Jan Küster

Hi Lizzy, what does the chrome console say?

Collapse
 
lizzymendivil profile image
Lizzy Mendivil

I added this:
if ("serviceWorker" in navigator) {
in serviceWorker.js file
So it never enters into the conditional

Thread Thread
 
jankapunkt profile image
Jan Küster

Please try the code as from the tutorial:

// serviceWorker.js
import { Meteor } from 'meteor/meteor'

Meteor.startup(() => {
  navigator.serviceWorker
    .register('/sw.js')
    .then(() => console.info('service worker registered'))
    .catch(error => { 
      console.log('ServiceWorker registration failed: ', error)
    })
})

does it throw an Error? If so, could you please show me the error stack?

Thread Thread
 
lizzymendivil profile image
Lizzy Mendivil
serviceWorker.js:5 Uncaught TypeError: Cannot read property 'register' of undefined
    at serviceWorker.js:5
    at maybeReady (meteor.js?hash=857dafb4b9dff17e29ed8498a22ea5b1a3d6b41d:938)
    at HTMLDocument.loadingCompleted (meteor.js?hash=857dafb4b9dff17e29ed8498a22ea5b1a3d6b41d:950)
Thread Thread
 
jankapunkt profile image
Jan Küster

Hm there seems to be no service worker in navigator. Is this a private session or do you block all cookies? I think there were some sw issues at least in Firefox that were related to these.

Thread Thread
 
lizzymendivil profile image
Lizzy Mendivil

well, i am using a virtual machine with ubuntu 16.04 but i connect through ssh and a network location and open the application in my window (physical machine)

Thread Thread
 
lizzymendivil profile image
Lizzy Mendivil

So, my url is 172.21.19.91:3000/
could it be the problem?

Thread Thread
 
lizzymendivil profile image
Lizzy Mendivil

JIC, I helped me
stackoverflow.com/questions/522992...

Now it is working fine! Thanks!