-
-
Save VARGA-Peter/12b8ded2136ac4e7b7bef6dd39d46a73 to your computer and use it in GitHub Desktop.
Check iOS version with Javascript
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
/** | |
* Returns the iOS version as string. For example 14.4.2 or 13.2.3. | |
* If the browser is not running under iOS "undefined" is returned. | |
*/ | |
function iOsGetVersion() | |
{ | |
const agentName = window.navigator.userAgent; | |
const matchingArray = agentName.match(/(iPhone|iPad).+ ([0-9_]+) .+/); | |
if( matchingArray ) { | |
return matchingArray [2].replaceAll( '_', '.' ); | |
} | |
return undefined; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The original version doesn't work anymore. Test with lot of user agents.