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) => {
Which device/browser are you testing this on?
I am using Chrome browser
Use this snippet:
if (navigator.serviceWorker !== undefined) {
console.log(‘haz serviceWorker support’);
} else {
console.log(‘you must be out on a safari’);
}
1 Like
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
Hi, use navigator[‘serviceWorker’] instead of navigator.serviceWorker.