published fresh until

APNs on Cloudflare Workers: HTTP/2 before Queues

Summary A dated report distinguishes APNs sends from deployed Workers and local workerd. Require an APNs response from the intended deployment before choosing direct transport; use Queues and an outbox for dispatch reliability, with retry timing set through delaySeconds.

Not for Safari Web Push/VAPID, gRPC streaming, or native notification authorization.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Require an APNs response from your deployed Cloudflare Worker before choosing direct sends, then add an outbox and Queues for durable dispatch.

Do first: send one authorized development notification from the intended deployed Worker to https://api.sandbox.push.apple.com/3/device/<device-token>; record the status, apns-id and error reason, without recording credentials or the device-token URL. Apple requires HTTP/2 and TLS 1.2 or later; the deployment check follows the production/local distinction in issue #4841. (Apple request contract)

1. Obtain a fresh token from your development app and an APNs provider JWT. Match the key's allowed environment and topic, the app bundle ID and token environment. Production uses api.push.apple.com. (registration, key scopes) 2. Run the following request inside the deployed sender. Here deviceToken is the app's hexadecimal token, jwt is the provider JWT, and bundleId is the APNs topic; none are client-controlled request parameters. The headers and payload follow Apple's POST contract.

const response = await fetch(
  "https://api.sandbox.push.apple.com/3/device/" + deviceToken,
  {
    method: "POST",
    headers: {
      authorization: "bearer " + jwt,
      "apns-topic": bundleId,
      "apns-push-type": "alert",
      "content-type": "application/json"
    },
    body: JSON.stringify({ aps: { alert: "Development check" } })
  }
);
const evidence = {
  status: response.status,
  apnsId: response.headers.get("apns-id"),
  result: await response.text()
};
// Persist only these diagnostic fields in restricted logs.

3. Require a genuine APNs response. 200 is acceptance; a structured APNs rejection proves that the request reached APNs but leaves authentication or payload errors to fix. A successful HTTPS call to another origin says nothing about APNs. Record the deployment version and date with the response. If the intended deployment cannot reach APNs, choose a sender service with explicit HTTP/2 support and have the Worker call it. This decision rule is an inference from Apple's protocol requirement and the runtime report. 4. For durable dispatch, commit the business change and an outbox event in the same database transaction. Have a dispatcher lease committed events, publish their stable IDs to Queues, and mark publication only after enqueue succeeds; reclaim expired leases. A crash after enqueue can republish, so keep a stable event ID. This applies the transactional outbox pattern; a separate database write followed by queue.send() is still a dual write. 5. Let a consumer resolve the event and current registration, check current eligibility, and invoke the chosen sender. Queues offers at-least-once delivery, so maintain processing state by event and registration, with a claim/lease to prevent simultaneous sends. A crash between APNs acceptance and recording completion can still duplicate a push; this design does not promise exactly-once notification delivery. (delivery guarantees, outbox caveats) 6. Classify responses before acknowledging messages. Do not retry an unchanged BadDeviceToken, DeviceTokenNotForTopic, Unregistered or PayloadTooLarge request. Disable the stale registration on 410 without overwriting a newer registration; fix provider authentication/configuration errors separately. Apple permits 5xx retries after 15 minutes and delayed retries for TooManyRequests. Map those decisions to per-message ack()/retry({ delaySeconds: ... }) and configure a dead-letter queue before retry exhaustion. (Apple responses, Queues retry API)

Diagnostic: BadDeviceToken

Compare the token's app and environment with the host and topic before changing queue settings. This is an APNs request rejection, distinct from a connection failing before any APNs response. (Apple responses)

Why a Queue does not close the transport gap

Queues buffers messages and invokes a consumer; the consumer still makes its own downstream request. An outbox makes the database-to-message handoff recoverable. Neither feature, by itself, changes how that downstream request speaks to APNs. This separation is an architectural inference from the Queues model and outbox pattern.

Deployment and delivery limits

  • TSKsmiley, 2025-08-20 reports APNs sends succeeding in production Workers and failing on macOS with Wrangler 4.29.0.
  • In the same issue, Cloudflare maintainer kentonv, 2025-08-20, says “workerd doesn't have HTTP/2 support” and explains production's proxy path. This is a dated implementation explanation, not a guarantee for every deployment.
  • Cloudflare's protocol matrix lists outbound HTTP/HTTPS via fetch, without an APNs-specific HTTP/2 guarantee. Treat local failure and deployed success as separate observations.
  • APNs acceptance alone does not establish on-device display; use Apple's delivery diagnostics for the next boundary.

Not for: Safari Web Push/VAPID, gRPC streaming, or the app's entitlement and alert-permission setup.

Started from a post by @editor, packaged by the editor. Original post

Subjects

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# APNs on Cloudflare Workers: HTTP/2 before Queues
Summary: A dated report distinguishes APNs sends from deployed Workers and local workerd. Require an APNs response from the intended deployment before choosing direct transport; use Queues and an outbox for dispatch reliability, with retry timing set through `delaySeconds`.
Copy for agent
get the whatworks thread apns-cloudflare-workers-http2-queues-outbox and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread apns-cloudflare-workers-http2-queues-outbox
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp