Skip to content

feat(push): fetch notification display data from v2 - #394

Merged
Quick104 merged 1 commit into
mainfrom
apiv2-stack/46-push-display-v2
Sep 23, 2026
Merged

Quick104 merged 1 commit into
mainfrom
apiv2-stack/46-push-display-v2

Conversation

@Quick104

Copy link
Copy Markdown
Contributor

The iOS NotificationService extension now fetches rich notification content from GET /api/v2/notifications/push/apple/display/{delivery_id} instead of the v1 route.

Problem

When a push arrives, the NotificationService extension fetches the title, body, thread and deep link from GET /api/v1/notifications/push/apple/display/{delivery_id}. ApplePushDisplayWire.displayURL builds that URL from path components ("api", "v1", ...), so a literal /api/v1 search does not find it (inventory rows 129, 132 and 136).

Solution

  • ApplePushDisplayWire.displayURL builds the v2 path. The request itself stays the same: the same Authorization: Bearer credential (display token first, mirrored access token second), X-Profile-Id, optional X-Profile-Token, and Accept: application/json.
  • The response model already matches the v2 NotificationPushDisplay schema (delivery_id, title, category and url required; body and thread_id optional). The server fixture notification_apple_push_display.json decodes without changes.
  • The extension keeps its own ephemeral URLSession with a 4-second budget. APIv2Client, HTTPClient and TokenStore are not linked into the extension target (project.yml SiloNotificationService sources), so it does not use the shared client. v2 returns application/problem+json for errors, but the extension only reads the status code. That keeps the 401/403 access-token fallback working.
  • Display tokens minted before this version: at server 84ed9e596, both the v1 route and the v2 operation run RequireApplePushDisplayAuth (internal/api/router.go displayMiddlewares, internal/apiv2/notification_inbox.go). Both routes accept the same apple_push_display token type (internal/auth/jwt.go). A token from the old v1 registration therefore works on the v2 route. This answers plan question S9 from source, not from a live server.

This is a read with no mutation, so there is no failure-outcome table. The failure behavior is unchanged: any error, including a timeout, leaves the generic APNs content in place.

Validation

  • iOS (including the SiloNotificationService extension), tvOS and macOS builds pass on this branch.
  • Focused iOS tests pass: ApplePushRegistrationTests and ApplePushOrderedRegistrationTests, 33 tests, 0 failures. Two new stub tests:
    • testDisplayFetchReadsV2AndRetriesARejectedDisplayTokenWithTheAccessToken: the display token gets a 401 problem, and the client retries once with the access token. Both requests use the v2 path with the same profile headers, and the response body is the server fixture's.
    • testDisplayFetchSurfacesANotFoundProblemWithoutRetrying: a 404 problem throws badStatus(404) after exactly one request.
  • The updated testNotificationDisplayEndpointURLAppendsDeliveryID asserts the v2 URL.
  • The push display code and its tests are iOS-only (#if os(iOS), and ApplePushRegistrationTests.swift is excluded from SiloTVTests), so tvOS has no tests to run.
  • scripts/ci/check-no-api-v1.sh passes.
  • The final stack passed the full suites (iOS 1981 tests, tvOS 1792 tests, 0 failures), the macOS build and the v1 path guard, and every branch in the stack builds on its own.

Risks and follow-ups

  • Not tested against a live server or a real APNs delivery. The token compatibility claim comes from reading the server source at 84ed9e596.
  • A server older than the v2 display operation returns 404, and those notifications show the generic APNs text. That matches the stack's no-v1-fallback rule.
  • The server fixture body is inlined in the test rather than vendored through scripts/sync-apiv2-fixtures.sh. Vendoring it would change SELECTED, SOURCE and index.json, which other lanes also edit. A later fixture sync can move it into SELECTED.

AI disclosure

Code and description written by Claude Opus 5.5 (claude-opus-5-5) agents in Claude Code (T3 Code), orchestrated by a Claude Code workflow.


Part 46 of 50 in the Apple API v2 stack. Base: apiv2-stack/45-apple-push-registration-v2. Merge in order from the bottom of the stack. The plan and full index are in PR 01.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: fd4bda16-0890-40fe-966a-41bdb67122de

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick104 has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-23T13:21:08.284487Z b5c3966 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Quick104

Copy link
Copy Markdown
Contributor Author

Code review summary

Reviewed head: f00649d8 (apiv2-stack/46-push-display-v2).

Process: an adversarial review of this PR's diff with each candidate finding independently verified before any fix, a simplify pass for medium and larger PRs, and a whole-stack review across contract conformance, authority and failure handling, data integrity, user-visible behavior and cross-PR integration.

Verified findings: none.

Validation: this branch builds on its own for iOS, tvOS and macOS, and its focused tests passed. The completed stack passed the full iOS suite (1981 tests) and tvOS suite (1792 tests) with 0 failures, the macOS build and the v1 path guard. The final stack was also exercised on iOS and tvOS simulators against a v1/v2 bridge server: sign-in (password and QR), restore, browse, search, detail, favorites and watchlist, playback (direct play, transcode, subtitles, stop), audiobooks, downloads with offline playback, settings, requests, profiles, push registration and diagnostics. Server logs showed no /api/v1 request from the new builds except the retained health probe.

Remaining: no open verified findings. Merge in stack order.

Mergeability: 8/10 — conditional. The approach holds up and every verified finding is fixed. Conditions: this PR's CI must pass (it was pending at review time), and the owner still plans a physical-device check of the completed stack.

Review by Claude Opus 5.5 (claude-opus-5-5) agents in Claude Code (T3 Code).

@Quick104
Quick104 force-pushed the apiv2-stack/46-push-display-v2 branch from f00649d to b5c3966 Compare September 23, 2026 13:19
@Quick104
Quick104 force-pushed the apiv2-stack/45-apple-push-registration-v2 branch from 5f61261 to 17c0244 Compare September 23, 2026 13:45
Base automatically changed from apiv2-stack/45-apple-push-registration-v2 to main September 23, 2026 13:45
The NotificationService extension still fetched rich notification
content from GET /api/v1/notifications/push/apple/display/{delivery_id}.
The URL was built from path components, so a literal /api/v1 search
missed it.

The extension now reads GET /api/v2/notifications/push/apple/display/
{delivery_id}. The response shape, headers and credentials are unchanged:
the server guards both routes with the same display-token middleware, so
display tokens minted before this version keep working, and the 401/403
fallback to the mirrored access token still applies. The extension keeps
its own URLSession because APIv2Client is not linked into it. New stub
tests pin the v2 path, headers, the access-token retry after a rejected
display token, and a 404 problem that is not retried.

Stack-PR: W5-U
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@Quick104
Quick104 force-pushed the apiv2-stack/46-push-display-v2 branch from b5c3966 to 1888b11 Compare September 23, 2026 13:45
@Quick104
Quick104 merged commit af820e6 into main Sep 23, 2026
2 checks passed
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@Quick104
Quick104 deleted the apiv2-stack/46-push-display-v2 branch September 23, 2026 13:45
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