Skip to content

Instantly share code, notes, and snippets.

@tiagopotencia
Last active March 27, 2017 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tiagopotencia/8bd91adb1fd87a2bb86cb55f54addfa8 to your computer and use it in GitHub Desktop.
Save tiagopotencia/8bd91adb1fd87a2bb86cb55f54addfa8 to your computer and use it in GitHub Desktop.
Detects if is Android or IOS. This code is very useful and i don't want to go Stackoverflow every time i need it LOL. Code from: http://stackoverflow.com/a/21742107
function getMobileOperatingSystem() {
var userAgent = navigator.userAgent || navigator.vendor || window.opera;
if (/android/i.test(userAgent)) {
return "Android";
}
// iOS detection from: http://stackoverflow.com/a/9039885/177710
if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {
return "iOS";
}
return "unknown";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment