ionic-framework: service worker does not work on device
Ionic version: (check one with “x”) [ ] 1.x [x] 2.x
I’m submitting a … (check one with “x”) [x] bug report [ ] feature request [ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/
Current behavior:
I have just enabled the service worker and it seems to be working just fine in the browser, but after I deployed to an Android device, I see the following:
DOMException: Failed to register a ServiceWorker: The URL protocol of the current origin ('file://') is not supported.
Expected behavior:
Service worker should work on a device.
Steps to reproduce:
Related code:
insert any relevant code here
Other information:
Ionic info: (run ionic info
from a terminal/cmd prompt and paste output below):
insert the output from ionic info here
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 15 (6 by maintainers)
Im just thinking is it really necessary to implement service workers in ionic?
What are the uses of service worker?
Ans:
But im looking for is there any framework or plugin to store the request and responses that are done automatically and use them when the app is offline.
But isn’t Ionic about mobile devices first and foremost? Ionic advertises its support for service workers and with some pride: http://blog.ionic.io/tag/service-workers/ I’ve spent most of the day yesterday setting it all app for what turns out to be a disappointment. Could Ionic make this clear somehow - as the comms are arguably misleading? Service Workers are a very desirable feature - built with mobile devices in mind. I think it is in cordova’s and Ionic (leading players in the field) interest to pursue this feature and bring it to the platform?
As a stopgap - and correct me if i’m wrong - service workers should work in ionic/cordova hosted app - where the app’s code is served from a server on install (and possibly/smartly cached - with service workers). Perhaps Ionic could provide a bootstrap setup (similar to https://ionicframework.com/getting-started/) for a hosted app where service workers can actually be taken advantage of…? Just an idea