javascriptcssprogressive-web-appstwa

How to distinguish between PWA and TWA in code?


How can one distinguish between an Android Trusted Web Activity (PWA wrapped in a WebView) and a Progressive Web App that has been added to the home screen (fullscreen mode)?

Is it possible in JS or CSS or even HTML5?

Edit: People are asking me what the differences are between a TWA and a PWA. I believe explaining this here is beyond the scope of this question. Please correct me if I'm wrong.


Solution

  • I found the answer here: How can I detect if my website is opened inside a Trusted Web Actvity?

    The question is formulated a bit differently, but it solves my problem as well. In short:

    document.referrer.includes('android-app://<twa.package.name>')