简体   繁体   English

代码中如何区分PWA和TWA?

[英]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)?如何区分 Android Trusted Web Activity(包含在 WebView 中的 PWA)和已添加到主屏幕(全屏模式)的 Progressive Web App?

Is it possible in JS or CSS or even HTML5?是否可以在 JS 或 CSS 甚至 HTML5 中使用?

Edit: People are asking me what the differences are between a TWA and a PWA.编辑:人们问我 TWA 和 PWA 之间有什么区别。 I believe explaining this here is beyond the scope of this question.我相信在这里解释这一点超出了这个问题的范围。 Please correct me if I'm wrong.如果我错了,请纠正我。

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>')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM