Skip to content

Instantly share code, notes, and snippets.

@IvoPereira
Last active February 4, 2025 08:08
Show Gist options
  • Save IvoPereira/5a5106cdf9819af385fad55925f96190 to your computer and use it in GitHub Desktop.
Save IvoPereira/5a5106cdf9819af385fad55925f96190 to your computer and use it in GitHub Desktop.
Detect if a PWA is installed (iOS Standalone, Trusted Web App, Chrome PWA)
function isPWA() {
return window.navigator.standalone == true || // iOS PWA Standalone
document.referrer.includes('android-app://') || // Android Trusted Web App
["fullscreen", "standalone", "minimal-ui"].some(
(displayMode) => window.matchMedia('(display-mode: ' + displayMode + ')').matches
) // Chrome PWA (supporting fullscreen, standalone, minimal-ui)
}
console.log(isPWA()) // true
@mohammadhacer
Copy link

Hi
i have use your code. but its not working and in all cases return false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment