ionic-team / capacitor

Build cross-platform Native Progressive Web Apps for iOS, Android, and the Web ⚡️
https://capacitorjs.com
MIT License
12.29k stars 1.01k forks source link

feat(android)!: Make service worker requests go through Capacitor bridge #7764

Open jcesarmobile opened 1 week ago

jcesarmobile commented 1 week ago

Marking it as breaking as some users might already have a similar code in their MainActivity file or in some plugin and will need to remove that code/plugin or disable Capacitor's registration if they want to keep their own handling.

markemer commented 6 days ago

Is there are good way to test this is working?

jcesarmobile commented 5 days ago

You can use https://github.com/jcesarmobile/app-capable which I created for a different thing, but exposes the problem (it doesn't have platforms added, you'll need to add android to test) Or also this one from an user https://github.com/radonirinamaminiaina/capacitor-sw

You'll see this error in logcat File: https://localhost/main.9677d6e520b8922e.js - Line 1 - Msg: Service worker registration failed with: TypeError: Failed to register a ServiceWorker for scope ('https://localhost/') with script ('https://localhost/ngsw-worker.js'): An unknown error occurred when fetching the script.

With this change applied the error is gone