如标题所述,我正在尝试检测我的网页是否在 samsungs stock 浏览器中被视为网页,或者它是否作为保存在主屏幕上的独立网络应用程序打开。但据我所知,我发现的用于执行此操作的 javascript 代码仅适用于 Safari 和 Chrome。
有人可以为此提供一个好的解决方案吗?
最佳答案
出于某种原因,window.matchMedia('(display-mode: standalone)').matches
在 Samsung Internet 安装的 PWA 上是 false
,即使它显示模式确实是 standalone
。
但是,您可以按照this answer中提供的方法进行操作,适用于三星互联网:
Set the start URL in the manifest file to include a query string parameter, ex:
"start_url": "./?mode=standalone"
Then in your JavaScript you are able to check for this query string parameter.
如果您处于独立模式,则地址栏对用户不可见,因此不会影响他们。
关于javascript - 检测页面是在三星股票浏览器中查看还是作为独立的网络应用程序查看,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53019733/