Problem 1
We can’t set up Shortcut Automations to be triggered when a PWA is opened form your home screen.
Problem 2
PWAs can’t be opened from one sec after the intervention, because they don’t register any URL Scheme.
First, let’s solve Problem 2
In order to be able to open the PWA after one sec’s intervention, you gonna have to create a new Shortcut that defines the URL Scheme “webapp://” and then opens it. If you run this shortcut, it should open the PWA. Unfortunately, we can’t differentiate between multiple PWAs. Configuring this URL Scheme directly in one sec does not work unfortunately, only the Shortcuts app seems to be capable to execute it.
Give the Shortcut a name like “Open appname”.
Proceed to one sec and add a new custom app: one sec → overview → + → add custom app. Use this URL Scheme to call the Shortcut you have just created:
shortcuts://run-shortcut?name=Open%20appname
Important: replace all spaces contained in the name with %20
You can press on “Test URL Scheme” in order to test if this actually proceeds to open the Shortcuts app which then proceeds to open the PWA.
Next, Solving Problem 1
Now that one sec is capable to open the PWA, we still have to trigger one sec every time you attempt to open the PWA.
This actually has a shortcoming, because we cant have it triggered by the original app icon. We have to add a Shortcut to the home screen as an alternative way to open the PWA. Alongside this, one sec also won’t be triggered if you open the PWA from multitasking or a push notification.
But yeah, if you really wanna do it, let’s create a new Shortcut in the Shortcuts app that just contains the 🅰️ Activate when appname opens.
Make sure you select the custom app you have created earlier here.
Next, give this Shortcut the same name as the PWA and change the Icon if you want. Then, add this Shortcut to your Home Screen via the Share Sheet. Hide the original PWA in some folder and only use the Shortcut to open this app from now on.
Well, it works, but is it worth all the effort? 🥹