Update iOS PWA after installed to homescreen/Use the Updates-API

Hey, first of all, Expo for web is quite lovely. Still, I am
struggeling with getting updates of my PWA to work. I would love to
hook into some kind of event that tells me, that there is a new
version available on the server and then be able to reload
cacheless. The Updates API for web seems to not support this behavior,
yet. The only ways I found were to either disable offline support or
to fiddle around with service workers.

On iOS, the PWA currently does not update at all, currently when it is
installed to the homescreen. That is an issue. Even if Safari has a
newer version, the PWA does not update.

Anything I overlooked? What might be the best way to archive
something like that?

Cheers

Apple currently makes it hard to support refresh due to their implementation for PWA.

Here’s how to do it:
Follow reload instructions here: https://gist.github.com/kawazoe/fa3b5a3c998d16871ffb9e2fd721cb4b

Then create a webpack.config.js


// Expo CLI will await this method so you can optionally return a promise.
module.exports = async function (env, argv) {
  const config = await createExpoWebpackConfigAsync(env, argv);
  if (config["plugins"]) {
    config["plugins"].forEach((plugin) => {
      // detect workbox plugin
      if (
        plugin["config"] &&
        plugin["config"]["swDest"] === "service-worker.js"
      ) {
        // tell it never to cache index.html or service-worker.js
        plugin["config"]["exclude"].push(/index.html/);
        plugin["config"]["exclude"].push(/service-worker.js/);
      }
    });
  }
  return config;
};

Hm, I tried to implement this solution for hours now. I have two main issues:

  • On Android, it does not refresh the app at all, I have to reload the page in Chrome and only then the PWA will update.
  • On iOS, sometimes (not sure when, might be after the second update), the PWA just starts into a blank white screen and there is nothing one can do about it. Even unpinning from home and readding does not help.

Any ideas, what this might be?