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
Implements the JS SDK side of paritytech/truapi RFC 0019 (scheduled push
notifications with idempotent cancellation).
BREAKING CHANGE: `host_push_notification` wire format changes — request gains
`scheduled_at: Option<u64>` (ms UTC), response becomes
`Result<NotificationId, PushNotificationError>` with `ScheduleLimitReached`
and `Unknown { reason }` variants. The prior wire format is replaced rather
than versioned alongside; hosts and products must upgrade together.
Protocol changes (v0.8 of host-api-protocol.md):
- `host_push_notification` carries the new `PushNotification` struct
- new `host_push_notification_cancel(NotificationId) -> Result<(), GenericErr>`
- both methods gated by `DevicePermission::Notifications`
SDK changes:
- host-api: `PushNotification`, `NotificationId`, `PushNotificationError`
- host-container: new `handlePushNotificationCancel`; existing
`handlePushNotification` returns `NotificationId` and rejects with
`PushNotificationError`
- host-api-wrapper: `createNotificationManager()` exposing
`.push({ text, deeplink?, scheduledAt? })` and `.cancel(id)`
Host-side persistence, OS-scheduler integration, and the platform-wide
queue cap remain host-application concerns; the SDK only transports
the typed error.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: docs/design/host-api-protocol.md
+47-1Lines changed: 47 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,13 @@ created: 2026-03-13
9
9
10
10
## Changelog
11
11
12
+
### v0.8 - 2026-05-14
13
+
14
+
-**Breaking change.** Extended `host_push_notification`: request gains `scheduled_at: Option<u64>` (Unix ms UTC) for deferred delivery; response changed from `Result<(), GenericErr>` to `Result<NotificationId, PushNotificationError>` (RFC-0019). The prior wire format is replaced rather than versioned alongside.
15
+
- Added `host_push_notification_cancel(NotificationId) -> Result<(), GenericErr>` for retracting a pending scheduled notification.
16
+
- Both methods are gated by `DevicePermission::Notifications`. No new permission variant.
17
+
-`NotificationId` is opaque per-product; cancellation is idempotent. Persistence, OS-scheduler integration, and the platform-wide queue cap are host-application concerns, not SDK concerns.
18
+
12
19
### v0.7 - 2026-04-13
13
20
14
21
- Renamed all `*_with_non_product_account` methods to `*_with_legacy_account`; renamed `host_get_non_product_accounts` to `host_get_legacy_accounts`; updated glossary term "Non-product account (NPA)" to "Legacy account".
Products can request the host to display a notification, either immediately or scheduled for a future wall-clock instant. Both methods are gated by `DevicePermission::Notifications`. See [RFC-0019](https://github.com/paritytech/truapi/blob/main/docs/rfcs/0019-scheduled-notifications.md) for the full motivation and host-side behavioural requirements (persistence, OS-scheduler integration, platform-wide queue cap).
501
+
502
+
```rust
503
+
typeNotificationId=u32;
504
+
505
+
structPushNotification {
506
+
// Notification body text.
507
+
text:String,
508
+
// Optional URL to open when the user taps the notification.
509
+
deeplink:Option<String>,
510
+
// Optional Unix timestamp in milliseconds (UTC) at which the notification should fire.
511
+
// `None` fires immediately, preserving prior behaviour. Past timestamps fire immediately.
512
+
scheduled_at:Option<u64>,
513
+
}
514
+
515
+
enumPushNotificationError {
516
+
// The host has reached its platform-wide cap on pending scheduled notifications.
517
+
// Only returned for scheduled (non-immediate) calls.
`NotificationId` is opaque and unique per product; the host MUST NOT leak ids across products. An id is returned for every call — immediate or scheduled — for shape uniformity. Cancellation is idempotent: `host_push_notification_cancel` MUST return `Ok(())` regardless of whether the id refers to a pending, already-fired, never-issued, or other-product's notification. This is a breaking change relative to the pre-v0.8 wire format; products and hosts must upgrade together.
532
+
487
533
#### Device permissions request
488
534
489
535
Products can request additional device permissions. This check is layered on top of platform permissions (web, iOS, Android) and adds a product-level security gate.
0 commit comments