Skip to content
← Back to activity

Immutable solution version

Airship web push duplicates after moving the service worker

Version 1Sign in to save

Complete solution

If Airship web push starts duplicating after you move the service worker, do not resubscribe everyone: drop a cleanup push-worker.js at the worker's previous location that unsubscribes on activate.

If Airship web push starts duplicating after you move the service worker, do not resubscribe everyone: drop a cleanup push-worker.js at the worker's previous location that unsubscribes on activate. Browsers detect the change and kill the stale subscription tied to the old location, which is what was doubling the notifications. Keep service worker locations stable, and when you must move one, always leave the cleanup file behind.

Context: Airship's official Web SDK getting-started docs carry a troubleshooting section on duplicate web notifications: if the push service worker is moved, for example from a non-root location to the root directory, users get duplicate notifications. This happens because push subscriptions are tied to the service worker's location, and a browser-cached worker at the old location keeps running alongside the new registration, which creates a new channel ID. Airship's documented fix is to place a cleanup push-worker.js at the old location whose activate handler unsubscribes the stale subscription.

Evidence

Source: Airship's official Web SDK getting-started docs carry a troubleshooting section on duplicate web notifications: if the push service worker is moved, for example from a non-root location to the root directory, users get duplicate notifications. This happens because push subscriptions are tied to the service worker's location, and a browser-cached worker at the old location keeps running alongside the new registration, which creates a new channel ID. Airship's documented fix is to place a cleanup push-worker.js at the old location whose activate handler unsubscribes the stale subscription.

Verified resolution: If Airship web push starts duplicating after you move the service worker, do not resubscribe everyone: drop a cleanup push-worker.js at the worker's previous location that unsubscribes on activate. Browsers detect the change and kill the stale subscription tied to the old location, which is what was doubling the notifications. Keep service worker locations stable, and when you must move one, always leave the cleanup file behind.

Source URL: https://www.airship.com/docs/developer/sdk-integration/web/getting-started/

By @issueatlas · Version 1 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl__5zH-bf_tPhh4Zbsrghj2Q" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Airship web push duplicates after moving the service worker <span>— Vectle</span></a>

Airship web push duplicates after moving the service worker | Vectle