mirror of
https://github.com/block/buzz.git
synced 2026-11-24 10:12:19 +00:00
Design docs for Android push notifications, matching what iOS has today: DM and mention notifications with real message text, grouped per conversation, and tapping one opens it. - **[ADR 0004](docs/adr/0004-push-gateway-hides-device-platform.md):** one push gateway per app distribution serves both platforms, and the relay can't tell an Android installation from an iOS one. - **[ADR 0005](docs/adr/0005-android-push-enrollment-attestation.md):** Android enrollment requires hardware Key Attestation on a locked bootloader, verified offline. Later installation calls are signed with the attested key. - **[ADR 0006](docs/adr/0006-android-notifications-run-app-dart-code.md):** Android builds notifications with the app's own Dart code in a background engine, instead of a native port of the iOS extension. - **[PLANS/ANDROID_PUSH.md](PLANS/ANDROID_PUSH.md):** the spec, plus the tickets it splits into. - **CONTEXT.md:** defines *wake signal* and *push gateway*. The privacy model stays the same: pushes carry a fixed wake signal and nothing about any event. ### Validation A throwaway [prototype](https://github.com/block/buzz/tree/prototype/android-push-headless-dart) checked ADR 0006 against FCM's ~10 s handler budget. It started a headless Dart engine from a killed app, signed in to a local relay and updated a placeholder notification with the real text. | Device | Wake to real text (median, 12 cold runs) | Memory (PSS) | |---|---|---| | Pixel 9a | 0.51 s (worst 0.54 s) | ~45 MB | | Emulator, CPU slowed ~8x | 0.80 s (worst 1.05 s) | ~57 MB | The relay ran on the same machine, so real network latency is still unmeasured. With an unresponsive relay, the placeholder notification stayed and the native watchdog ended the handler. This PR changes documentation only, so no app run applies. ### Regressions None. This PR adds documentation only and changes no behavior. The design keeps iOS push working through the rollout, and the relay learns no more about devices than it does today. --------- Signed-off-by: Tom Brow <tomb@squareup.com> Co-authored-by: Tom Brow <tomb@squareup.com>
14 lines
1.9 KiB
Markdown
14 lines
1.9 KiB
Markdown
# Android notifications are built by the app's own Dart code
|
|
|
|
On iOS, a native Swift notification service extension fetches and formats each notification. On Android, the push handler instead starts the app's Dart code in a background engine, without the UI, and that code fetches the message from the relay and builds the notification. This reuses the app's relay, sign-in and formatting code rather than porting the iOS extension to Kotlin. A prototype showed it fits Android's time limit for handling a push: on an emulator, the real text appeared about 0.1 s after a cold wake, and about 1 s with the CPU slowed 8x, against a budget of about 10 s.
|
|
|
|
The handler posts the fetched notifications directly, because the category (and so the channel the user may have silenced) is known only after the fetch. If nothing is posted within about 2 s, it posts a generic notification in a separate "Other" category, which the real result replaces silently. A slow or failed fetch therefore still leaves a visible notification, and Android deprioritizes apps whose high-priority pushes show nothing. While the app is in the foreground the handler does nothing. Unlike the iOS extension, which can only rewrite the push it was handed, the handler posts every eligible unshown message it finds, grouped per conversation, so a wake means "sync now". The background path uses its own short network timeouts and a native watchdog, because the app's normal connect and sign-in timeouts are longer than the budget.
|
|
|
|
## Considered options
|
|
|
|
- **Port the iOS extension to Kotlin.** That means a second native copy of fetching, sign-in and formatting to keep in step with the app.
|
|
|
|
## Consequences
|
|
|
|
iOS could later share this Dart code too, but a notification service extension's memory limit (about 24 MB) is well below the background engine's footprint (about 57 MB in the prototype), so that needs its own measurement and work first.
|