Cantuariensis
Cantuariensis

Reputation: 35

How to exit my PWA after sending data with Web Share Target?

If I share a picture from Google Photos to my PWA (installed with Chrome on Android and using this code https://web.dev/web-share-target/), I arrive on my PWA page. How to go back automatically to Google Photo?
Backend is in PHP if that matters.
Thanks!

Upvotes: 1

Views: 592

Answers (1)

Jeff Posnick
Jeff Posnick

Reputation: 56044

I haven't tested this, but have you tried redirecting from your service worker's fetch event handler to an HTML page that immediately uses this technique to close itself?

Something like:

self.addEventListener('fetch', (event) => {
  // ...process the incoming event.request body here...

  // Once you're done, respond with a redirect:
  event.respondWith(Response.redirect('/self-closing-page.html', 303));
});

And then your /self-closing-page.html web page would just close itself. That would (maybe?) leave you back in the original Android app.

Upvotes: 1

Related Questions