Skip to content

Instantly share code, notes, and snippets.

@IvoPereira
Last active June 3, 2024 11:03
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment