Explorar o código

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

Nihal Gonsalves %!s(int64=2) %!d(string=hai) anos
pai
achega
66ef28c2e2

BIN=BIN
docs/static/img/pwa-install-macos-safari-add-to-dock.png


+ 7 - 0
docs/subscribe/pwa.md

@@ -26,6 +26,13 @@ app drawer:
     <a href="../../static/img/pwa-badge.png"><img src="../../static/img/pwa-badge.png"/></a>
 </div>
 
+### Safari on macOS
+To install and register the web app via Safari, click on the Share menu and click Add to Dock. You need to be on macOS Sonoma (14) or higher.
+
+<div id="pwa-screenshots-safari-desktop" class="screenshots">
+    <a href="../../static/img/pwa-install-macos-safari-add-to-dock.png"><img src="../../static/img/pwa-install-macos-safari-add-to-dock.png"/></a>
+</div>
+
 ### Chrome/Firefox on Android
 For Chrome on Android, either click the "Add to Home Screen" banner at the bottom of the screen, or select "Install app"
 in the menu, and then click "Install" in the popup menu. After installation, you can find the app in your app drawer, 

+ 10 - 2
web/src/app/Notifier.js

@@ -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
+    );
   }
 }