fix: Enable PWA support for iOS devices (#1120)

* Enable PWA support for iOS devices

* add sniff for ios <12.2
opengraph-tweaks
sgenoud 2019-03-31 19:56:21 +02:00 zatwierdzone przez Nolan Lawson
rodzic f169e0063d
commit 8d012a96f7
1 zmienionych plików z 7 dodań i 3 usunięć

Wyświetl plik

@ -51,8 +51,12 @@ if (/mac/i.test(navigator.platform)) {
document.documentElement.style.setProperty('--scrollbar-border-radius', '50px')
}
// TODO: remove this hack when Safari works with cross-origin window.open()
// in a PWA: https://github.com/nolanlawson/pinafore/issues/45
if (/iP(?:hone|ad|od)/.test(navigator.userAgent)) {
// Versions of iOS Safari before iOS 12.2 do not work properly as a PWA
// for cross-origin authentication: https://github.com/nolanlawson/pinafore/issues/45
// Here we sniff for iOS <12.2 by checking for the existence of a native IntersectionObserver
// function, which was added in 12.2.
if (/iP(?:hone|ad|od)/.test(navigator.userAgent) &&
!(typeof IntersectionObserver === 'function' &&
IntersectionObserver.toString().includes('[native code]'))) {
document.head.removeChild(document.getElementById('theManifest'))
}