Skip to content
Advertisement

How to check if IOS/Safari version below 15 or 15 and higher

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

Advertisement

Answer

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)
    }
  }, [])
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement