PWA referral Codes – sharing data between initial browser and subsequent PWA installation

I’m looking to implement a referral code system for my PWA.
The goal is to allow existing users to share a ref-link with their friends who can then install the app and get some benefits or have their app pre-configured.

So user A shares his ref link app.foo.com/?refCode=123 with his friends.
They open it on their mobile browser and are prompted to install the PWA.

Once they open the installed PWA, they create their account and log in.

I’m looking for a way now to share the refCode from the original link that user B opens in his browser to the installed PWA context where he then creates his account (and can forward the refCode to our backend to track it).

From what I’ve read IndexedDB should have worked (since it’s same origin – both app.foo.com) but at least in iOS it doesn’t. It appears the PWA runs in a different context and does not share the same IndexedDB context (objectStore not found).

Also tried localstorage after coming across some rumours it’s supported now in iOS 17+, but doesn’t appear to be the case either.

I don’t want to introduce invasive fingerprinting and would prefer not to burden the UX flow with the users having to share or enter specific codes manually etc.

Is there a solution to share data between the initial browser context and the subsequent installed PWA context (for both iOS and Android)?