Skip to content

feat: add opt-in banner for push notifications#76

Open
ClickAndGoScript wants to merge 3 commits into
NodeBB:mainfrom
ClickAndGoScript:pr/3-opt-in-banner
Open

feat: add opt-in banner for push notifications#76
ClickAndGoScript wants to merge 3 commits into
NodeBB:mainfrom
ClickAndGoScript:pr/3-opt-in-banner

Conversation

@ClickAndGoScript

Copy link
Copy Markdown

Adds an optional corner banner that invites logged-in users to enable push
notifications. It's off by default; the ACP has a toggle and a setting for how
many page visits to wait before showing it.

The banner is only shown on devices that actually support push (Service Worker

  • PushManager available, permission not already denied, SW registered). Visit
    count and dismissal are stored in localStorage per device, so it won't reappear
    after the user dismisses it or subscribes.

Part of #64.

- Add he (Hebrew) translation for all existing strings
- Complete zh-CN translation (missing strings added)
- Move hardcoded test notification text in library.js to [[web-push:test.*]]
- Move hardcoded admin nav label in library.js to [[web-push:admin.menu-label]]
- Replace hardcoded strings in ACP template with [[web-push:admin.*]] keys
…tness

- Add "Mark as read" and "View notifications" action buttons to push notifications,
  translated server-side per user language (en-GB, he, zh-CN)
- Service worker handles button clicks: mark-read calls the write API directly
  without needing an open window; view-notifications focuses/opens the notifications page
- Pass nid in notification data payload so mark-read can identify the notification
- settings.js: add browser support detection (serviceWorker + PushManager)
- settings.js: race serviceWorker.ready against a 5s timeout to avoid infinite
  hang when no SW is registered (common on iOS before PWA install)
- settings.js: handle permission denied before and after requestPermission()
- settings.js: roll back browser-level subscription on API failure
- settings.js: show success toast on subscribe
- Corner banner invites logged-in users to subscribe after a configurable
  number of page visits; dismissal and visit count stored in localStorage
- Banner is shown only on supported devices (serviceWorker + PushManager available,
  permission not denied, SW registered)
- ACP setting to enable/disable the banner and configure the visit threshold
- Banner and all admin strings fully translated (en-GB, he, zh-CN)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant