Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 272
Chris Avatar asked Jan 09 '20 11:01

Chris


1 Answers

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>')
like image 61
Chris Avatar answered Oct 30 '22 15:10

Chris