function isPWA() {
// Check if the app is in "standalone" mode (installed as a PWA)
return window.matchMedia('(display-mode: standalone)').matches || window.navigator.standalone;
}
// PWA yes or no
const isStandalone = window.matchMedia('(display-mode: standalone)').matches || window.navigator.standalone;
if (isStandalone) {
console.log("App is PWA standalone");
fetch('your-server-script.php', {
method: 'POST',
body: JSON.stringify({ pwaMode: true }),
headers: { 'Content-Type': 'application/json' }
});
} else {
console.log("App is normal");
fetch('your-server-script.php', {
method: 'POST',
body: JSON.stringify({ pwaMode: false }),
headers: { 'Content-Type': 'application/json' }
});
}
$data = json_decode(file_get_contents('php://input'), true);
if ($data && isset($data['pwaMode'])) {
$isPWA = $data['pwaMode']; // True is PWA, False no PWA
}