From 7a702114eb344c23349f0aa66f7dc3e52b924501 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 6 Aug 2026 17:36:31 +0000 Subject: [PATCH] feat: iOS push instruction banner + fix edge-functions security.ts exports --- public/service-worker.js | 2 +- .../client/PushSubscriptionBanner.jsx | 44 +++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) 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 уведомления работают только если приложение добавлено на главный экран. +

+
    +
  1. 1. Нажмите «Поделиться» (квадрат со стрелкой ↑) внизу Safari
  2. +
  3. 2. Выберите «На экран Домой» → «Добавить»
  4. +
  5. 3. Откройте приложение с иконки «СуперСам» на главном экране
  6. +
  7. 4. Нажмите «Разрешить» в этом баннере
  8. +
+
+
+
+ +
+
+ ); + } + // Subscribed state — show small confirmation + unsubscribe option if (status === "subscribed") { return (