I'm a newbie on PWA, so I had similar trouble with Samsung browser.
looks like it's been about 3 years since many people posted the problem, for me, it was still hard to find a better solution because "start_url" wasn't enough.
I googled and looked into ways to solve this problem and it seems like I did it. Finally, the post resolved my problem.
In my case, I only considered and tested chrome browser, Samsung browser and safari browser. You will be able to customize if you want as I commented on the source code.
const BROWSER_TAB = "browser-tab";
const STAND_ALONE = "standalone";
const getDisplayMode = () => {
let displayMode = BROWSER_TAB;
if (window.navigator.standalone || window.matchMedia("(display-mode: standalone)").matches) {
displayMode = STAND_ALONE; // PWA
} else if (
window.screen.height - document.documentElement.clientHeight <
100
) {
displayMode = STAND_ALONE; // PLAY_STORE, (maybe AppStore as well)
} else if (
new URLSearchParams(window.location.search).get("source") === "pwa" // "start_url": "/?source=pwa", from menifest.json
) {
displayMode = STAND_ALONE; // IOS or PWA or PLAY_STORE but it only works on start_url in menifest.json
}
return displayMode;
};
I hope this helps even though it's not a perfect solution.