Skip to content

Instantly share code, notes, and snippets.

@Antoinebr
Last active June 8, 2020 12:56
Show Gist options
  • Save Antoinebr/edc06d1ef1a4001afd2266a43638221f to your computer and use it in GitHub Desktop.
Save Antoinebr/edc06d1ef1a4001afd2266a43638221f to your computer and use it in GitHub Desktop.

Detect standalone IOS

// Detects if device is on iOS 
const isIos = () => {
  const userAgent = window.navigator.userAgent.toLowerCase();
  return /iphone|ipad|ipod/.test( userAgent );
}
// Detects if device is in standalone mode
const isInStandaloneMode = () => ('standalone' in window.navigator) && (window.navigator.standalone);

// Checks if should display install popup notification:
if (isIos() && !isInStandaloneMode()) {
  
    // "IOS : Not launched form the Home Screen";

}else if (isIos()){
  
   // "IOS : LAUNCHED form the Home Screen";
}
@charisTheo
Copy link

charisTheo commented May 8, 2020

Can you detect iOS 13 with this?
Never tested it but from this StackOverflow answer it seems that you will need to use an additional check for iOS 13

const isIos13 = navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1;

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