Created
February 28, 2024 11:22
-
-
Save SonyStone/73d131095f024dac78df71cee60c4461 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
export function isWebview() { | |
const navigator = window.navigator; | |
const userAgent = navigator.userAgent; | |
const normalizedUserAgent = userAgent.toLowerCase(); | |
const standalone = (navigator as any).standalone; | |
const isIos = | |
/ip(ad|hone|od)/.test(normalizedUserAgent) || | |
(navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1); | |
const isAndroid = /android/.test(normalizedUserAgent); | |
const isSafari = /safari/.test(normalizedUserAgent); | |
const isWebview = | |
(isAndroid && /; wv\)/.test(normalizedUserAgent)) || | |
(isIos && !standalone && !isSafari); | |
return isWebview; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment