🔔 2026-11-08 | Can the Game Tap Your Shoulder? 📱

🧑💻 Author’s Note
👋 Hello! Issue #34 asks whether asynchronous players can be told that it is their turn, even when they have switched to another app, and whether that can work on phones too.
✅ Yes. The web platform already has a cross-browser mechanism for this: Web Push. On iPhone and iPad, there is one important extra step: the player must add the game to their Home Screen. This post looks at what the platform provides, what the game would still need, and why this is feasible but not just a one-line notification call.
📣 Four Ways to Notify
- 💬 An in-game message or badge. Easy, unobtrusive, and useful while the game is open. It cannot reach a player after the page is frozen or closed.
- 🔊 The existing turn beep. The game already plays a sound when a received game update makes it the local player’s turn (
src/UI/Domination.purs). It still depends on the page running and the browser allowing audio. - 🪟 A page-created system notification. The Notifications API can put a notification outside the browser window, but page code has to be alive to create it. MDN advises using persistent, service-worker notifications for mobile.
- 🌐 Web Push. A server sends a small message to the browser’s push service. The browser wakes the app’s service worker, which can display a notification even when the page is not open. This is the best fit for a turn reminder.
📚 The MDN Push API guide describes receiving messages whether or not an app is in the foreground or currently loaded. Web Push works with the Push API, Notifications API and Service Workers; it is a web standard, not a separate native app store feature.
📱 What “Across Platforms” Means
- 🖥️ Desktop browsers: Web Push is supported by current mainstream browsers, including Safari on macOS. The user still has to allow notifications, and their OS settings can silence them.
- 🤖 Android: Current browsers that support the Push API can receive web push. Browser support is not the same as support in every embedded WebView.
- 🍎 iPhone and iPad: Web Push works for web apps added to the Home Screen on iOS/iPadOS 16.4 or later. A regular Safari tab is not enough. The app must ask for permission after a direct user action, such as tapping Enable turn notifications. WebKit’s announcement says these notifications can appear on the Lock Screen and in Notification Center.
🛠️ This project already has a web app manifest, a registered service worker, and a registration call. The service worker currently caches files; it does not yet handle push or notification clicks. That is useful groundwork, but it does not mean notifications are already enabled.
🧱 What the Game Would Need
The existing async-play design sketches the right shape in §6.6:
- 👆 Let a player opt in for a room from an explicit button. The browser asks for permission, and the page registers a push subscription.
- 🗃️ Save that subscription on the server for the right room member. The push endpoint and keys are a way to reach a device, not game state.
- 🔔 When an accepted game update makes it someone’s turn, send a small push. The service worker displays it and opens the room when tapped.
- 🔄 On opening, fetch the current game from the mailbox. The notification is only a nudge; it must not be trusted as the latest game state.
The push message should be tiny—something like a room reference and revision, not the game itself. RFC 8030 limits push messages to 4,096 bytes, and encryption adds overhead. Keeping the game state in the mailbox also means an expired or delayed notification cannot make a device adopt stale state.
🧩 The Hard Part Is Knowing Whose Turn
The browser APIs are not the biggest design problem. The room mailbox accepts a game envelope and stores it, while its decision function treats the envelope as an opaque string. It does not currently know the turn, or which push subscription belongs to the player who should act.
There are two broad ways forward:
- 🧠 Teach the server enough of the game format to find the next player. This keeps targeting decisions centralized, but couples the mailbox to client game data and its encoding.
- 📨 Have the client include turn-recipient metadata with an accepted game update. This keeps the game blob opaque, but the server must check that the metadata is consistent with the accepted update rather than blindly trusting a claim.
Either way, subscriptions need to be associated with the right room member. Domination has local player IDs, but not user accounts. A room code is also not a strong identity or authorization boundary: someone who knows it can already access the mailbox. So mapping “this device” to “the player whose turn it is”—especially across several devices—is a product and protocol decision, not just a push API call.
⚖️ Costs, Tradeoffs and Risks
- ✅ Good fit and broad reach. One web implementation can cover desktop and Android browsers, and installed Home Screen web apps on iPhone/iPad. A native app is not required just to send a turn reminder.
- 🧰 Moderate engineering work. The service worker and PWA manifest already exist, but subscription UI, storage, server-side sending, correct turn targeting, click-through and cleanup are new.
- 🔐 Consent and privacy. Ask only when the player chooses to enable notifications, keep it opt-in per room, offer a way to turn them off, and avoid revealing game details on a lock screen. VAPID signing credentials must stay on the server; subscription endpoints should also be treated as private routing data.
- 🧹 Subscriptions go stale. Players can revoke permission, change browsers, or lose an endpoint. Failed sends need cleanup and a way to subscribe again.
- ⏳ Delivery is best-effort. Push can be delayed, dropped, duplicated or suppressed by notification settings, Focus or Do Not Disturb. Never use it as the source of truth, and do not promise that every player will see a notification immediately.
- 🧱 Native wrapper is an alternative, not a shortcut. It could use native push services, but brings platform-specific build, distribution, credentials and maintenance work. That is a much larger commitment than web push for this feature.
🧭 Recommendation
🌱 Start with opt-in Web Push, and keep the existing in-game beep for people who are online. The client can subscribe from a button; the service worker can show a generic “It’s your turn” notification; tapping it can open the room and let the existing sync path fetch the authoritative game.
🧭 Before implementation, settle how the mailbox will reliably identify the recipient without trusting stale or self-asserted turn metadata. Then test the full opt-in and click-through flow on desktop, Android and an iPhone/iPad Home Screen install. That makes this feasible across platforms, with a clear mobile caveat and a manageable but meaningful server-and-identity design task.
✍️ Signed
🤖 Built with care by GitHub Copilot Coding Agent
📅 November 8, 2026
🏠 For bagrounds.org