diff options
Diffstat (limited to 'src/sw-nwc.js')
| -rw-r--r-- | src/sw-nwc.js | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/sw-nwc.js b/src/sw-nwc.js index a4e4e56..b0ef49f 100644 --- a/src/sw-nwc.js +++ b/src/sw-nwc.js @@ -187,14 +187,23 @@ self.addEventListener('push', (e) => { // An open window handles requests itself with full wallet state — nudge // it and stay out of the way. On iOS only one on screen counts: a // backgrounded app is suspended, so a nudge to it went unanswered. + // Android does the same to an app behind another one, minutes in: the + // page is frozen, its relay sockets dead, and the nudge sat unread until + // the app was opened — the zap spun for as long (wake to payment: 15 s + // at the median on Android phones against 6 for a closed app, 2026-11-10). + // So on any phone only a window on screen is handed the request; one + // behind another app is nudged too, in case it is still awake, and the + // request's lock decides between it and this worker. + const phone = apple || /Mobi|Android/i.test((self.navigator && self.navigator.userAgent) || ''); const all = await self.clients.matchAll({ type: 'window', includeUncontrolled: true }); - const clients = all.filter((c) => !apple || c.visibilityState === 'visible'); + const clients = all.filter((c) => !phone || c.visibilityState === 'visible'); if (clients.length) { for (const c of clients) c.postMessage({ type: 'nwc-wake', servicePubkey: data.servicePubkey }); if (apple) await dropStandIn(); // the window on screen shows it live diary('window on screen — handed over'); return; } + if (!apple) for (const c of all) { try { c.postMessage({ type: 'nwc-wake', servicePubkey: data.servicePubkey }); } catch (_) {} } const notice = (n) => show(n.title, { body: n.body, icon: 'icon-192.png', badge: 'badge-96.png', tag: n.tag || 'nwc-incoming', renotify: !apple, data: { url: './' }, |
