You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 3e9fcfa
Browse filesBrowse the repository at this point in the historyBrowse files
fix(push): make iOS background delivery actually work (#728)
* fix(push): make iOS background delivery actually work
Delivery investigation on a real iOS home-screen web app showed that
background pushes never arrived while the same subscriptions worked once
the VAPID subject was corrected. Three independent causes, all fixed here:
1. Invalid VAPID subject: Apple's push service rejects
`mailto:pi-web@localhost` with 403 BadJwtToken, so every send failed
before leaving the server. The subject now defaults to the project
homepage (a valid https URL) and can be overridden with
PI_WEB_PUSH_SUBJECT.
2. Subscription poisoning via suppressed notifications: the service
worker skipped showNotification whenever an app window was visible.
iOS revokes the push subscription when a push is handled without a
notification, so every foreground-observed completion silently
poisoned the subscription until background delivery stopped entirely
(servers keep getting 201 from APNs, so nothing visible in logs).
The SW now always shows the notification; same-tag notifications
replace each other, so a visible window just sees it re-appear.
3. Deferred delivery: sends had no Urgency/TTL, so iOS may defer them to
an arbitrary later wake-up window. Sends now use urgency=high with a
4-week TTL.
Also adds a "register push" control to Settings → General. On iOS the
permission prompt must run inside a user gesture and cannot be
re-triggered after a home-screen re-install, and the previous code only
subscribed automatically after a task completion, which could leave a
freshly installed home-screen app without any subscription path. The
button reuses setupPushSubscription() and lives next to the language
section.
Verified: node --test (push/sw suites 15/15), eslint, tsc --noEmit.
* fix(push): allow permission prompts and retries
---------
Co-authored-by: nannant666 <nannant666@users.noreply.github.com>
Co-authored-by: Alex Yang <agegcn@gmail.com>
"settings.pushPermissionDescription": "After adding this site to your home screen (iOS 16.4+), a system notification is shown on the lock screen when a session finishes while no window is visible. If notifications stop arriving, re-register here. Registration needs a user gesture, so it is never triggered automatically.",
41
+
"settings.pushRegister": "Register push",
42
+
"settings.pushRegisterLoading": "Registering…",
43
+
"settings.pushRegistered": "✅ Push registered — background notifications are ready.",
0 commit comments