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, I arrive on my PWA page. How to go back automatically to Google Photo?
Backend is in PHP if that matters.


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.