User notification systems (platforms + self-hosted)
Research for Host-owned notify (see root CONTEXT.md).
Question: how do mature platforms let apps request user-visible notifications, and how do users control importance/channels without letting apps bypass preferences?
Executive finding
Across Android, Apple, Nextcloud, and Matrix, the durable pattern is the same:
- Apps declare categories / types and may suggest importance or default channels.
- The platform (or homeserver) owns delivery — in-app inbox, email, push — and Apps never talk to FCM/APNs/Web Push themselves in the self-hosted models surveyed.
- Users own the effective interrupt policy after first registration; apps cannot raise importance once the user (or OS) has lowered it.
- Push is a wake channel, often with encrypted or
event_id_onlypayloads; the full notification body lives on the server the client already trusts.
For personal-cloud: Apps should post a typed notification request to the Host; Host + account preferences choose whether/how to surface it; Apps must tolerate silence.
Summary matrix
| System | Who declares categories | Who sets priority / interrupt | User control | Delivery backends | App owns transport? |
|---|---|---|---|---|---|
| Android channels | App creates NotificationChannel (id, name, initial importance) |
App sets initial channel importance; user can change anytime; app cannot change importance after create | Per-channel importance / mute | System notification shade (+ optional FCM for remote) | Local: yes via NotificationManager. Remote: usually vendor push — not Host-shaped |
| Apple UserNotifications | App registers UNNotificationCategory (actions); per-notification interruptionLevel |
App requests auth options + suggests interruption level; user can deny / Focus / change settings | Authorization (alert/sound/badge), provisional, Focus / Time Sensitive entitlements | Local schedule or APNs remote | Remote requires APNs; app does not bypass OS permission |
| Nextcloud | App id + subject keys; Activity types via ISetting |
No Android-style importance ladder on the PHP notify API; Activity prefs per type × channel | Personal Notifications matrix (mail / push / stream); email batching | In-app Notifications app, Activity stream, email, push (proxy or UnifiedPush) | No — server IManager::notify; push via proxy / distributor |
| Matrix | Homeserver events + push rules (not per-app channels) | Push rules choose notify / tweaks; gateway prio high|low |
User push rules (incl. master mute); per-room mute | Homeserver → Push Gateway → APNs/FCM/Web Push / UnifiedPush | No — client registers pusher; HS owns /notify |
Android: notification channels and importance
Spec / docs
From Android 8.0 (API 26), every notification must belong to a channel. Apps create channels with a unique id, user-visible name, and importance, then register them with NotificationManager.createNotificationChannel (Create and manage notification channels; Create a notification).
Importance levels (NotificationManager.IMPORTANCE_*) map to user-visible interrupt behavior (NotificationManager; design guide Notifications):
| Level | Typical behavior |
|---|---|
IMPORTANCE_HIGH |
Sound + heads-up |
IMPORTANCE_DEFAULT |
Sound |
IMPORTANCE_LOW |
No sound |
IMPORTANCE_MIN |
Shade only, minimal status-bar presence |
IMPORTANCE_NONE |
Blocked / no shade |
Who controls what
- App: declares channels; picks initial importance; posts notifications into a channel id.
- After create: the app cannot change the channel’s importance; the user can redefine channel preferences anytime (channels docs).
- The system may also adjust behavior; docs warn that requested importance is not guaranteed (Create a notification).
Lesson
Treat App-supplied importance as a suggestion at channel registration. Host settings UI should expose per-App (or per-category) controls the App cannot escalate after the user dials down.
Apple: permission, categories, interruption levels
Authorization
Apps must call UNUserNotificationCenter.requestAuthorization(options:) for alert / sound / badge (and may use provisional authorization for quiet delivery without an immediate prompt). Users can change settings later; apps must check getNotificationSettings before assuming delivery (Asking permission to use notifications; authorizationStatus).
Statuses include notDetermined, denied, authorized, provisional, and time-limited forms (UNAuthorizationStatus).
Categories vs importance
UNNotificationCategory: declares actionable types (buttons), registered viasetNotificationCategories; payloads referencecategoryIdentifier/aps.category(UNNotificationCategory).- Interruption levels (
UNNotificationInterruptionLevel):passive,active(default),timeSensitive,critical— control how aggressively the system presents the notification; Time Sensitive / Critical need entitlements and can break through Focus / mute in constrained ways (UNNotificationInterruptionLevel; WWDC21 session 10091).
Lesson
Separate category (what kind / what actions) from interruption (how loud). Both are App-suggested; OS + user Focus policies win. A Host capability can mirror: typed categories + suggested urgency, with account Focus-like mutes.
Nextcloud: Host-shaped notifications + push without App sockets
In-app notify API (Apps do not own transport)
Apps obtain \OCP\Notification\IManager, build an INotification (setApp, setUser, setDateTime, setObject, setSubject mandatory — language keys, not translated strings), then notify(). A registered INotifier prepares display strings at read time (notification-workflow.md).
Pattern match for personal-cloud: App posts structured intent; Host/Shell localizes and renders; App can markProcessed when obsolete.
Activity preferences (user channel matrix)
Separately, the Activity app lets Apps register activity types (OCP\Activity\ISetting) that appear on Settings → Personal → Notifications. Users toggle mail / push / stream (and email batching / daily summary) per type (User manual — Activity; Activity API — ISetting). Admins set defaults for new accounts only (Activity admin).
Push: proxy model (Apps still don’t own FCM/APNs)
Store-signed mobile clients cannot ship Nextcloud’s vendor push credentials on every self-hosted server. Nextcloud’s design (push-v2.md):
- Device registers
pushTokenHash+ device public key + proxy URL with the Nextcloud server. - Server encrypts payload to the device key and signs with the user key; sends to push-notifications.nextcloud.com (or configured proxy).
- Proxy holds the real FCM/APNs credentials; vendors never learn the originating Nextcloud URL.
- Device verifies signature and decrypts; may fetch full notification via OCS using
nid.
UnifiedPush is an alternate path (e.g. Talk + “Allow web push” + distributor such as Sunup/NextPush): App Server → Push Server → phone Distributor → app (Talk UnifiedPush notes; UnifiedPush definitions). Same principle: server posts to a push system; the end-user app does not open vendor sockets for arbitrary hosts.
Lesson
Strong Host-owned story: notification object store + optional wake via push proxy / UnifiedPush. Prefer encrypted or minimal push payloads; full body stays on the Instance. User prefs are per type × channel, not App-controlled.
Matrix: push rules + push gateway (homeserver owns delivery)
Architecture
Homeserver → Push Gateway (POST /_matrix/push/v1/notify) → vendor Push Provider. Clients register a pusher (gateway URL + pushkey) via Client-Server API; they do not have the homeserver speak APNs directly (Push Gateway API; Client-Server — Push Notifications).
prio on the notify body is high | low (default high) for battery-aware delivery. format: event_id_only lets gateways wake the client with ids only; client fetches content from the homeserver (Push Gateway API).
User control: push rules (not App channels)
Push rules live on the homeserver, reusable across clients. Kinds (priority order): override → content → room → sender → underride. Actions include notify and set_tweak (e.g. sound, highlight). If no rule matches, the HS must not notify. Default .m.rule.master can disable all pushes when enabled (Client-Server Push Notifications).
Lesson
User policy is a rules engine on the Host, not something Apps negotiate per message. Apps (rooms/events) emit facts; Host evaluates rules → maybe push. Fits personal-cloud if Dataset/Host events feed notifications under account rules.
Cross-cutting lessons for notify
- Host owns transport. Apps call a Host API (Nextcloud
IManager, Matrix HS push pipeline). No App sockets to FCM/APNs/SMTP for “notify the user.” - Categories / types are first-class. Android channels, Apple categories, Nextcloud Activity
ISettingids, Matrix room/sender rules — users need named buckets to mute without nuking everything. - Suggested urgency ≠ enforced urgency. Android channel importance and Apple interruption levels are App hints; user/OS wins. Spec should say Apps must tolerate denial, downgrade, and batching.
- Separate in-app inbox from interrupt channels. Nextcloud Notifications + Activity mail/push matrix; Matrix notifications list vs push. Host system events (e.g. stale Dataset) can use the same pipeline without an App capability (already noted on the catalog ticket).
- Push is wake + optional ciphertext. Prefer Instance-held body + push as signal (
nid/event_id_only), especially for self-hosted trust. - Relationship to email: Nextcloud routes some types to mail under user prefs and batching — not “App sends email because it wanted a notification.” Align with vision
emailvsnotifyon the grilling ticket. - Multi-account: Nextcloud notifications are per user (
setUser); Matrix rules are per Matrix user. Map to personal-cloud account as the preference subject (and App Grant context already install×account).
Prompts for the grilling ticket
- Manifest-declared notification categories (with rationale i18n) vs runtime-only types?
- App-suggested importance ceiling vs Host defaults?
- V1 delivery: Shell inbox only, vs + email, vs + push (UnifiedPush / proxy) as vision?
- Must Apps observe “delivered / suppressed” feedback, or fire-and-forget?
- How Host system notifications share UI without
notifyon an App.