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

* Enable PWA support for iOS devices

* add sniff for ios <12.2
This commit is contained in:
sgenoud 2019-03-31 19:56:21 +02:00 committed by Nolan Lawson
parent f169e0063d
commit 8d012a96f7

View file

@ -51,8 +51,12 @@ if (/mac/i.test(navigator.platform)) {
document.documentElement.style.setProperty('--scrollbar-border-radius', '50px') document.documentElement.style.setProperty('--scrollbar-border-radius', '50px')
} }
// TODO: remove this hack when Safari works with cross-origin window.open() // Versions of iOS Safari before iOS 12.2 do not work properly as a PWA
// in a PWA: https://github.com/nolanlawson/pinafore/issues/45 // for cross-origin authentication: https://github.com/nolanlawson/pinafore/issues/45
if (/iP(?:hone|ad|od)/.test(navigator.userAgent)) { // 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')) document.head.removeChild(document.getElementById('theManifest'))
} }