I'm working on a PWA that plays music. It accepts shared URLs from other android apps via Web Share Target API.
The problem : Whenever something is shared via the API (which uses GET request)I my PWA is reloded (as expected). And the already playing Music stops because of that.
Is there any way that page doesn't reload ?
Currently fetching shared params with this code.
const parsedUrl = new URL(window.location);
My PWA is a Single Page application
Thanks
One way to prevent reloading is by setting up a fake path in your Web Application Manifest that solely serves for the purpose of receiving shares (note that this uses HTTP POST and "multipart/form-data" encoding [so later you can extend the app to receive entire files]):
Then in your service worker's fetch handler, you deal with the incoming shares and redirect the user to the home: