Although not recommended (in this web.dev article) I have the situation of two nested PWAs:
- app "A" - the outer/global one, scope: "example.com"
- app "B" - the inner one with scope: "example.com/m/subproduct"
In both of these PWAs I can visit the page example.com/m/subproduct/test. In the JavaScript environment I'd now like to detect if the user is using app A or B for this pageview - so far without success.
I basically need a way to query the manifest info that was used during installation, but I don't think there is any JS Api to e.g. get the start-url.
I also thought about using some kind of localStorage/sessionStorage mechanism to remember the context during installation but since the domain is the same it also means that the storage scope is the same. In addition, this data could be wiped, so it's not reliable.
Using special start-urls to store something in the sessionStorage (when a certain get-parameter is detected) might be a way to differentiate sessions that are started via the app launcher, but it would also miss a lot of other ways to trigger the app-opening.
I also considered checking the currently installed/active service workers but they are the same as well.
I saw this article about a new AppID mechanism but again I don't see a way to query this ID in the JS context
Is there any way to access the currently installed manifest or any other way that I don't see to reliably detect which app is used?
The only idea I had so far was using different values for the "display" property because we can detect if it's standalone or not via this:
matchMedia('(display-mode: standalone)').matches
... but this is not really an option since I need "standalone" for both apps. I'd need something to e.g. query the theme color so I can differentiate as a workaround - any ideas?