GoogleChrome / android-browser-helper

The Android Browser Helper library helps developers use Custom Tabs and Trusted Web Activities on top of the AndroidX browser support library.
Apache License 2.0
694 stars 288 forks source link

Isolating TWA local storage #456

Open tristan-morris opened 11 months ago

tristan-morris commented 11 months ago

We have an install base of ~50k users with a TWA backed by Bubblewrap. As background, we've also tweaked Bubblewrap to coerce the engine selection to use Chrome for consistency. For the vast majority of users there are absolutely no problems at all and it's a great UX and DX.

For 0.002% of users Google Play Warriors, there are two main issues which show up:

  1. Users complain about the App being a browser. I assume from the occasional address bar which flashes up on App load, and the prompt about being run in a Chrome context. This is less of an issue but related.
  2. Users reset the App's state by clearing Chrome's history/browsing data. I think this is more of an issue, as users don't expect the App's state to also be cleared.

Describe the solution you'd like As a possible solution to 1 and 2, but really to prompt some discussion: it would be nice if there was an option to have local storage isolated to the TWA/App context and it would be unchanged by 2 (clearing history). And if local storage was isolated, then there's less need for prompting/warning the user, addressing 1? If a developer opted into isolated storage, it would be nice if there was a prompt/workflow to migrate state from local storage to app context local storage.

Describe alternatives you've considered Migrating to another framework which embeds the browser engine/context. Big issue here is migrating users, especially around notification subscriptions, login state etc. I also enjoy the DX of tight integration and the UX is great for users who visit the website, have a PWA ready to go and then converting to TWA users, so I'm less keen to drop what works well.

Additional context Happy to add any further context.