diff --git a/public/service-worker.js b/public/service-worker.js index 9e88b04..fe60654 100644 --- a/public/service-worker.js +++ b/public/service-worker.js @@ -1,7 +1,7 @@ const isLocalhost = self.location.hostname === "localhost" || self.location.hostname === "127.0.0.1"; if (!isLocalhost) { - const STATIC_CACHE = "construction-delivery-static-v104"; + const STATIC_CACHE = "construction-delivery-static-v105"; const RUNTIME_CACHE = "construction-delivery-runtime-v104"; const APP_SHELL_URLS = ["/", "/index.html", "/manifest.webmanifest", "/icons/icon-192.png", "/icons/icon-512.png"]; diff --git a/src/components/client/PushSubscriptionBanner.jsx b/src/components/client/PushSubscriptionBanner.jsx index 89aa6c4..cc4b705 100644 --- a/src/components/client/PushSubscriptionBanner.jsx +++ b/src/components/client/PushSubscriptionBanner.jsx @@ -35,8 +35,18 @@ export const PushSubscriptionBanner = ({ phone, orderGroupId }) => { const [dismissed, setDismissed] = useState(false); const phoneNorm = normalizePhone(phone); + // Detect iOS Safari (not in standalone mode = not added to Home Screen) + const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; + const isStandalone = window.matchMedia("(display-mode: standalone)").matches || navigator.standalone === true; + const isIOSNotInstalled = isIOS && !isStandalone; + // Check if push is supported useEffect(() => { + // iOS Safari in browser mode (not standalone) doesn't support Push API + if (isIOSNotInstalled) { + setStatus("ios_not_installed"); + return; + } if (!("serviceWorker" in navigator) || !("PushManager" in window)) { setStatus("unsupported"); return; @@ -119,6 +129,40 @@ export const PushSubscriptionBanner = ({ phone, orderGroupId }) => { if (status === "unsupported" || !phoneNorm) return null; if (dismissed && status !== "subscribed" && status !== "denied") return null; + // iOS not installed — show instruction to add to Home Screen + if (status === "ios_not_installed") { + return ( +
+ Включить уведомления о доставке +
++ На iPhone уведомления работают только если приложение добавлено на главный экран. +
+