Apple Live Activities

Run ActivityKit start, update, end, and iOS 18 broadcast delivery through Sockudo's durable push pipeline.

8 min read
View .mdEdit on GitHub

Apple Live Activities

This page covers driving iOS Live Activities from your server through Sockudo: starting an activity remotely, updating and ending it, and broadcasting one update to millions of devices through iOS 18 channels. Use it when your app shows live state on the Lock Screen or Dynamic Island (rides, deliveries, scores, builds) and that state changes on your backend.

Sockudo supports the complete server-side ActivityKit lifecycle:

  • token-based push-to-start, update, and end notifications
  • automatic <bundle-id>.push-type.liveactivity topics
  • direct priority 5 (conservePower) and 10 (immediate), plus broadcast-only priority 1 (lowPower)
  • stale-date, dismissal-date, relevance score, alerts, and iOS 18 input push token/channel fields
  • iOS 18 broadcast channel create, inspect, delete, update, and end
  • durable admission, scheduling, idempotency, retry, dead letters, status, metrics, and backpressure from the normal push pipeline

Sockudo builds and validates the APNs wire payload. Callers use camel-case typed fields and never need to construct hyphenated aps keys or APNs headers themselves. The implementation follows Apple’s ActivityKit remote update contract, APNs request contract, broadcast request contract, and channel management contract.

Three ways to reach an activity

Every Live Activity request is a normal push publish with two additions: a Live Activity recipient and a typed liveActivity object. Which recipient you use depends on what you are doing.

GoalRecipient transportTypeToken or IDAllowed events
Start a new activity remotelyapnsLiveActivityThe app’s push-to-start tokenstart
Update or end one specific activityapnsLiveActivityThat activity’s update tokenupdate, end
Update or end every activity watching shared contentapnsLiveActivityBroadcastA broadcast channel ID plus its storagePolicyupdate, end

Direct tokens cost one APNs request per activity. A broadcast channel costs one APNs request no matter how many devices subscribe, which is why shared content (a match score, a flight status) belongs on a channel.

iOS app
Your backend
Sockudo
APNs
1push-to-start token
2publish start
3liveactivity push
4activity starts
5activity update token
6publish update or end
7liveactivity push
8content state changes
sequenceDiagram
  participant App as iOS app
  participant BE as Your backend
  participant S as Sockudo
  participant APNs as APNs

  App->>BE: push-to-start token
  BE->>S: publish start
  S->>APNs: liveactivity push
  APNs-->>App: activity starts
  App->>BE: activity update token
  BE->>S: publish update or end
  S->>APNs: liveactivity push
  APNs-->>App: content state changes

Apple app setup

Enable Push Notifications and Live Activities for the application and widget extension. Add NSSupportsLiveActivities to the app’s Info.plist. If the product needs higher-frequency updates, also add NSSupportsLiveActivitiesFrequentUpdates; users can still disable frequent updates, so the app should observe ActivityKit authorization changes and tolerate coalescing.

Server configuration

  1. Build the server with push-apns. Add monolith when the same process should run the durable planner, dispatcher, APNs delivery, feedback, repair, and cleanup workers:

    Terminal window
    cargo build -p sockudo --release --features "push-apns,monolith"

    Without monolith, run the push worker roles separately; the HTTP API and broadcast-channel management surface remain available in the server process.

  2. Enable APNs, Live Activities, and (optionally) broadcast under [push] and [push.apns]:

    config.toml
    [push]
    apns_enabled = true
    dispatch_worker_count = 8
    dispatch_max_outbound_requests = 256
    [push.apns]
    topic = "com.example.rides"
    live_activities_enabled = true
    bundle_id = "com.example.rides"
    live_activity_topic = "" # derives com.example.rides.push-type.liveactivity
    broadcast_enabled = true
    endpoint = "https://api.push.apple.com"
    broadcast_endpoint = "https://api-broadcast.push.apple.com"
    management_endpoint = "https://api-manage-broadcast.push.apple.com:2196"
    default_broadcast_expiration_secs = 3600
    connect_timeout_ms = 5000
    request_timeout_ms = 10000
    pool_idle_timeout_secs = 90
    max_idle_connections_per_host = 128
    tcp_keepalive_secs = 60
    http2_keepalive_interval_secs = 30
    http2_keepalive_timeout_secs = 10
    ca_certificate_path = "" # optional extra PEM roots
  3. Provide APNs credentials, either as a stored credential (POST /apps/{appId}/push/credentials/apns plus PUSH_APNS_APP_ID) or through PUSH_APNS_TEAM_ID, PUSH_APNS_KEY_ID, and PUSH_APNS_PRIVATE_KEY_PATH. See Provider credentials.

  4. Start the server. Configuration is validated at boot; an invalid combination fails fast with the offending push.apns.* key.

Startup validation enforces these rules:

RuleError when violated
live_activities_enabled requires push.apns_enabled.push.apns.live_activities_enabled requires push.apns_enabled
broadcast_enabled requires live_activities_enabled.push.apns.broadcast_enabled requires push.apns.live_activities_enabled
topic must be set when APNs is enabled. bundle_id falls back to topic.push.apns.topic must not be empty when APNs is enabled
live_activity_topic, when set, must equal <bundle_id>.push-type.liveactivity.push.apns.live_activity_topic must equal <bundle_id>.push-type.liveactivity
default_broadcast_expiration_secs must be between 1 and 28800 (eight hours).push.apns.default_broadcast_expiration_secs must be between 1 and 28800
All three endpoints must be https URLs without user information.push.apns.<name> must be an HTTPS URL without user information

ca_certificate_path adds root certificates to the built-in public roots for every APNs, broadcast, and channel-management connection. Use it for private egress proxies or for staged rollouts against an APNs-compatible mock; leave it empty to trust only Apple’s public certificate chain.

Broadcast channel management supports the same APNs token or mTLS credential stored for dispatch. For token authentication, configure teamId, keyId, and a .p8 private key, or a short-lived provider token. APNs provider JWTs are cached for 55 minutes and invalidated once on ExpiredProviderToken; Sockudo does not regenerate them more frequently than Apple’s recommended interval. Secrets remain in the existing encrypted credential store or secret environment variables.

lowPower maps to APNs priority 1 and is valid only for broadcast requests. Direct token delivery uses conservePower (5, the default) or immediate (10).

The liveActivity object

FieldTypeMeaning
eventstart, update, or endThe ActivityKit event.
timestampUNIX secondsRequired and positive. Keep it current and monotonically ordered per activity.
contentStateobjectRequired. Must match your Activity.ContentState.
attributesTypestringThe ActivityAttributes type name. Start only.
attributesobjectStatic activity attributes. Start only.
alertobjectAlert shown with the push. Required for start.
staleDateUNIX secondsWhen the content becomes stale. Update only.
dismissalDateUNIX secondsWhen an ended activity leaves the Lock Screen. End only.
relevanceScorenumberFinite and non-negative. Orders multiple activities.
inputPushTokenbooleaniOS 18: ask the started activity for an update token. Start only.
inputPushChannelstringiOS 18: subscribe the started activity to a broadcast channel. Start only.
prioritylowPower, conservePower, immediateAPNs priority 1, 5, or 10. Defaults to conservePower.

Sockudo rejects a publish with 400 when:

  • a Live Activity recipient is present but liveActivity is missing;
  • liveActivity is combined with an APNs entry in providerOverrides;
  • a start omits attributesType, attributes, or alert, or sets staleDate or dismissalDate;
  • an update sets start fields, dismissalDate, inputPushToken, or inputPushChannel;
  • an end sets start fields, staleDate, inputPushToken, or inputPushChannel;
  • inputPushToken and inputPushChannel are both set;
  • lowPower is used for direct (non-broadcast) delivery;
  • a broadcast recipient carries a start event.

Start from a push-to-start token

Broadcast notifications cannot start an activity. Send a start request to a push-to-start token:

POST /apps/{appId}/push/publish
Content-Type: application/json
x-sockudo-push-capability: push-admin
{
"publishId": "ride-184-start-v1",
"recipients": [{
"type": "recipient",
"recipient": {
"transportType": "apnsLiveActivity",
"activityToken": "PUSH_TO_START_TOKEN"
}
}],
"payload": {},
"liveActivity": {
"event": "start",
"timestamp": 1725000000,
"contentState": { "status": "driverAssigned", "etaMinutes": 4 },
"attributesType": "RideAttributes",
"attributes": { "rideID": "ride-184" },
"alert": { "title": "Driver assigned", "body": "Arriving in 4 minutes" },
"inputPushToken": true,
"priority": "immediate"
}
}
202 Accepted
{
"publishId": "ride-184-start-v1",
"status": "accepted",
"expectedRecipients": 1,
"fanoutRegime": "fastPath"
}

The real response also includes renderedPayloads, one preview per provider; it is omitted here.

On iOS 18, use either inputPushToken: true or inputPushChannel: "CHANNEL_ID", never both. The channel form lets the newly started activity subscribe directly to a broadcast channel.

Update or end one activity

Use the activity’s current update token with transportType: "apnsLiveActivity". An update may set staleDate; an end may set dismissalDate. Keep timestamp current and monotonically ordered for a given activity.

Update
{
"publishId": "ride-184-update-42",
"recipients": [{
"type": "recipient",
"recipient": {
"transportType": "apnsLiveActivity",
"activityToken": "CURRENT_ACTIVITY_UPDATE_TOKEN"
}
}],
"payload": {},
"liveActivity": {
"event": "update",
"timestamp": 1725000042,
"contentState": { "status": "arriving", "etaMinutes": 1 },
"staleDate": 1725000162,
"relevanceScore": 0.9,
"priority": "conservePower"
}
}
End
{
"publishId": "ride-184-end",
"recipients": [{
"type": "recipient",
"recipient": {
"transportType": "apnsLiveActivity",
"activityToken": "CURRENT_ACTIVITY_UPDATE_TOKEN"
}
}],
"payload": {},
"liveActivity": {
"event": "end",
"timestamp": 1725000300,
"contentState": { "status": "completed", "etaMinutes": 0 },
"dismissalDate": 1725003900
}
}

Broadcast at large scale

  1. Create a channel through the signed, push-admin API:

    POST /apps/{appId}/push/liveActivities/channels
    Content-Type: application/json
    {"storagePolicy":"mostRecent"}
    201 Created
    { "channelId": "CHANNEL_ID", "storagePolicy": "mostRecent" }
  2. Store the returned channelId and storagePolicy with the event it represents, and hand the channel ID to apps so they can start activities with inputPushChannel.

  3. Publish updates to the channel with an apnsLiveActivityBroadcast recipient (example below).

  4. Delete the channel when the event is over.

storagePolicy is noStorage (the default) or mostRecent. noStorage maximizes the broadcast budget and always sends apns-expiration: 0. mostRecent lets APNs retain only the latest notification for offline devices, for at most eight hours. The policy is immutable: include the returned storagePolicy in every publish target so Sockudo can apply the matching expiration rules.

Apple permits up to 10,000 channels per app in each environment. Reconcile the APNs inventory with your event registry using the read endpoints:

RequestResponse
GET /apps/{appId}/push/liveActivities/channels200 with { "channels": ["CHANNEL_ID", ...] }
GET /apps/{appId}/push/liveActivities/channels/{channelId}200 with { "channelId": "...", "storagePolicy": "..." }
DELETE /apps/{appId}/push/liveActivities/channels/{channelId}204 No Content

Channel endpoints return 422 feature_disabled unless both push.apns_enabled and push.apns.broadcast_enabled are set. APNs 429 and 5xx responses from channel management surface as 503; other APNs rejections surface as 400.

Broadcast update
{
"publishId": "match-90-score-3-1",
"recipients": [{
"type": "recipient",
"recipient": {
"transportType": "apnsLiveActivityBroadcast",
"channelId": "CHANNEL_ID",
"storagePolicy": "mostRecent"
}
}],
"payload": {},
"expiresAtMs": 1725003600000,
"liveActivity": {
"event": "update",
"timestamp": 1725000000,
"contentState": { "home": 3, "away": 1 },
"priority": "conservePower"
}
}

A broadcast target is one provider request regardless of subscriber count. Consequently, expectedRecipients is 1; delivery status means APNs accepted the broadcast, not that every device displayed it. Use Apple’s Push Notifications Console and delivery metrics for downstream visibility.

Swift token observation

RideActivityController.swift
let updateTask = SockudoLiveActivityTokens.observePushTokens(for: activity) {
activityID, token in
await backend.replaceLiveActivityToken(activityID: activityID, token: token)
}
if #available(iOS 17.2, *) {
let startTask = SockudoLiveActivityTokens.observePushToStartTokens(
for: RideAttributes.self
) { token in
await backend.replacePushToStartToken(token)
}
}

Keep the returned task for as long as tokens are needed and cancel it when ownership ends. Tokens are delivered as hexadecimal strings, ready to send as activityToken.

Local end-to-end example

examples/apple-live-activities-backend runs the whole path without Apple credentials: a mock APNs in Docker that enforces Apple’s wire contract, a ride-tracking backend built on the Node server SDK, and a scenario that verifies every request the server makes. Its run.sh builds Sockudo with push-apns,monolith and trusts the mock’s CA through ca_certificate_path. The example also ships an iOS Simulator app with a Live Activity widget that exercises the Swift token observers against the backend; the Simulator needs real sandbox APNs credentials to display pushed updates, because simctl push cannot deliver liveactivity pushes.

Capacity and failure handling

Sockudo reuses long-lived HTTP/2 connections, enables adaptive flow-control windows, and bounds each worker’s concurrent outbound requests. Direct-token fanout remains O(number of activities); use broadcast channels for audiences that share content. Increase worker count and outbound concurrency gradually while watching APNs 429 responses, queue lag, retry age, circuit state, and provider latency. More sockets do not guarantee more APNs throughput.

ConditionBehavior
Payload too largeThe APNs device payload limit is 4096 bytes and the broadcast limit is 5120 bytes. Sockudo checks the final serialized body for the actual destination.
APNs 429 or 5xxRetried with jitter and Retry-After.
APNs 5xxHolds only that payload for Apple’s required 15-minute delay; other Live Activity deliveries keep flowing, and repeated 5xx failures trip the normal provider circuit breaker.
Invalid token or channel, configuration failure, caller payload errorTerminal and observable, without leaking tokens.
Retried requestReuses the same apns-id (direct) or apns-request-id (broadcast). Sockudo supplies both deterministically.

The dedicated sockudo_push_apns_live_activity_requests_total{mode,event,status,app} counter separates direct and broadcast outcomes while the common push queue, retry, provider-failure, and latency metrics retain the full operational picture.

Next steps