问题
Neither one of the methods used to detect standalone mode in Chrome Android work in my PWA
This is the CSS method I tried
@media all and (display-mode: standalone) {
/* Here goes the CSS rules that will only apply if app is running standalone */
}
And this is the Javascript method (line 171-175, 297-306)
function isRunningStandalone() {
return (window.matchMedia('(display-mode: standalone)').matches);
}
...
if (isRunningStandalone()) {
/* This code will be executed if app is running standalone */
}
Neither one of them worked: Testing isRunningStandalone() remotely in Chrome Android returns false, even though the example works.
(example made by @josemmo here)
I have tested the code in iOS and 3 different Android Phones. iOS works perfectly.
回答1:
I found the solution to the problem: manifest.json has to have "display": "standalone"
"display": "fullscreen" will not work. I could not test for it either.
来源:https://stackoverflow.com/questions/54640893/pwa-running-fullscreen-in-chrome-android-does-not-honor-display-mode-standalone