Property 'serviceWorker' does not exist on type 'Navigator'


#1

Hi I am getting below error when building ionic 2 app by un-commenting service worker code

Property ‘serviceWorker’ does not exist on type ‘Navigator’.

if (‘serviceWorker’ in navigator) {
navigator.serviceWorker.register(‘service-worker.js’)
.then((subscription: any) => {


#2

Which device/browser are you testing this on?


#3

I am using Chrome browser


#4

Use this snippet:
if (navigator.serviceWorker !== undefined) {
console.log(‘haz serviceWorker support’);
} else {
console.log(‘you must be out on a safari’);
}


#5

Hi, I am using iOS device and trying to load PWA app but I am not getting ‘serviceWorker’ in navigator. Is it not supported in Safari/iOS device. But it’s working in Browser in Mac and android device


#6

Hi, use navigator[‘serviceWorker’] instead of navigator.serviceWorker.