As someone new to the world of PWA, I encountered a similar issue with the Samsung browser.
It seems that many others have faced this problem in the past few years, and despite searching for a solution, the simple "start_url" wasn't enough for me.
After some extensive googling and exploring different avenues, I stumbled upon a helpful post that finally resolved my dilemma. You can read more about it here.
In my own experience, I focused on testing the behavior of the Chrome, Samsung, and Safari browsers. Feel free to customize this approach according to your needs by making adjustments in 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;
};
While not a foolproof solution, I hope this information proves useful to you in navigating through similar challenges.