0

I need to detect user IOS/Safari version and if its below 15 do not render some content for him, cause it doesn't support under 15 versions

I've tried to use

navigator.userAgent

So i see in the console the Safari version, but not quiet understand how to check if it 15 or below

xVarlordx
  • 23
  • 3
  • Check this answer --> [stackOverflow answer](https://stackoverflow.com/questions/8348139/detect-ios-version-less-than-5-with-javascript) – Erikwski Dec 07 '22 at 12:27

1 Answers1

0

I think i find solution For me works well:

const [ifSafariSupportedAr, setIfSafariSupportedAr] = useState(false)

  useEffect(() => {
    if (navigator.userAgent.includes('Safari/')) {
      const array = [...navigator.userAgent.split('Version/')[1]]
      const [first, second] = array
      const version = first + second
      setIfSafariSupportedAr(+version >= 15)
    }
  }, [])
xVarlordx
  • 23
  • 3