Skip to content

Instantly share code, notes, and snippets.

@realsby
Created April 23, 2018 17:41
Show Gist options
  • Save realsby/bae4993131ef03054af1a264599776e8 to your computer and use it in GitHub Desktop.
Save realsby/bae4993131ef03054af1a264599776e8 to your computer and use it in GitHub Desktop.
Redirect mobile app in browser
getMobileOperatingSystem();
function getMobileOperatingSystem() {
var userAgent = navigator.userAgent || navigator.vendor || window.opera;
if (/android/i.test(userAgent)) {
window.location = "https://play.google.com/store/apps/details?id=TTTTTTT"
return "Android";
}
if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {
window.location = "https://itunes.apple.com/us/app/TTTTTTT/TTTTTTT";
return "iOS";
}
return "unknown";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment