feat: iOS push instruction banner + fix edge-functions security.ts exports
This commit is contained in:
parent
2597835352
commit
7a702114eb
|
|
@ -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"];
|
||||
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<div className="rounded-xl border border-[rgba(18,128,92,0.2)] bg-[var(--color-accent-soft)] px-4 py-3">
|
||||
<div className="flex items-start gap-2.5">
|
||||
<span className="text-base flex-shrink-0 mt-0.5">🔔</span>
|
||||
<div className="flex-1">
|
||||
<p className="text-sm font-semibold text-[var(--color-text)]">
|
||||
Включить уведомления о доставке
|
||||
</p>
|
||||
<p className="text-xs text-[var(--color-text-muted)] mt-1 leading-5">
|
||||
На iPhone уведомления работают только если приложение добавлено на главный экран.
|
||||
</p>
|
||||
<ol className="text-xs text-[var(--color-text-muted)] mt-2 space-y-1 leading-5">
|
||||
<li>1. Нажмите <span className="font-medium">«Поделиться»</span> (квадрат со стрелкой ↑) внизу Safari</li>
|
||||
<li>2. Выберите <span className="font-medium">«На экран Домой»</span> → «Добавить»</li>
|
||||
<li>3. Откройте приложение с иконки <span className="font-medium">«СуперСам»</span> на главном экране</li>
|
||||
<li>4. Нажмите <span className="font-medium">«Разрешить»</span> в этом баннере</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex justify-end mt-2">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setDismissed(true)}
|
||||
className="text-xs text-[var(--color-text-muted)] transition hover:text-[var(--color-text)]"
|
||||
>
|
||||
Позже
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// Subscribed state — show small confirmation + unsubscribe option
|
||||
if (status === "subscribed") {
|
||||
return (
|
||||
|
|
|
|||
Loading…
Reference in New Issue