Last active
March 27, 2017 16:54
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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