fix(pwa): hide install prompt on macos 14 safari

This commit is contained in:
Nihal Gonsalves 2023-09-27 23:16:05 +02:00
parent 19c30fc411
commit 66ef28c2e2
3 changed files with 17 additions and 2 deletions

View file

@ -124,9 +124,17 @@ class Notifier {
return window.location.protocol === "https:" || window.location.hostname.match("^127.") || window.location.hostname === "localhost";
}
// no PushManager when not installed, but it _is_ supported.
iosSupportedButInstallRequired() {
// no PushManager when not installed, but it _is_ supported.
return config.enable_web_push && "serviceWorker" in navigator && window.navigator.standalone === false;
return (
config.enable_web_push &&
// a service worker exists
"serviceWorker" in navigator &&
// but the pushmanager API is missing, which implies we're on an iOS device without installing
!("PushManager" in window) &&
// check that this is the case by checking for `standalone`, which only exists on Safari
window.navigator.standalone === false
);
}
}