Apple Live Activities
Run ActivityKit start, update, end, and iOS 18 broadcast delivery through Sockudo's durable push pipeline.
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.liveactivitytopics - 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.
| Goal | Recipient transportType | Token or ID | Allowed events |
|---|---|---|---|
| Start a new activity remotely | apnsLiveActivity | The app’s push-to-start token | start |
| Update or end one specific activity | apnsLiveActivity | That activity’s update token | update, end |
| Update or end every activity watching shared content | apnsLiveActivityBroadcast | A broadcast channel ID plus its storagePolicy | update, 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.
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
-
Build the server with
push-apns. Addmonolithwhen 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. -
Enable APNs, Live Activities, and (optionally) broadcast under
[push]and[push.apns]:config.toml [push]apns_enabled = truedispatch_worker_count = 8dispatch_max_outbound_requests = 256[push.apns]topic = "com.example.rides"live_activities_enabled = truebundle_id = "com.example.rides"live_activity_topic = "" # derives com.example.rides.push-type.liveactivitybroadcast_enabled = trueendpoint = "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 = 3600connect_timeout_ms = 5000request_timeout_ms = 10000pool_idle_timeout_secs = 90max_idle_connections_per_host = 128tcp_keepalive_secs = 60http2_keepalive_interval_secs = 30http2_keepalive_timeout_secs = 10ca_certificate_path = "" # optional extra PEM roots -
Provide APNs credentials, either as a stored credential (
POST /apps/{appId}/push/credentials/apnsplusPUSH_APNS_APP_ID) or throughPUSH_APNS_TEAM_ID,PUSH_APNS_KEY_ID, andPUSH_APNS_PRIVATE_KEY_PATH. See Provider credentials. -
Start the server. Configuration is validated at boot; an invalid combination fails fast with the offending
push.apns.*key.
Startup validation enforces these rules:
| Rule | Error 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
| Field | Type | Meaning |
|---|---|---|
event | start, update, or end | The ActivityKit event. |
timestamp | UNIX seconds | Required and positive. Keep it current and monotonically ordered per activity. |
contentState | object | Required. Must match your Activity.ContentState. |
attributesType | string | The ActivityAttributes type name. Start only. |
attributes | object | Static activity attributes. Start only. |
alert | object | Alert shown with the push. Required for start. |
staleDate | UNIX seconds | When the content becomes stale. Update only. |
dismissalDate | UNIX seconds | When an ended activity leaves the Lock Screen. End only. |
relevanceScore | number | Finite and non-negative. Orders multiple activities. |
inputPushToken | boolean | iOS 18: ask the started activity for an update token. Start only. |
inputPushChannel | string | iOS 18: subscribe the started activity to a broadcast channel. Start only. |
priority | lowPower, conservePower, immediate | APNs priority 1, 5, or 10. Defaults to conservePower. |
Sockudo rejects a publish with 400 when:
- a Live Activity recipient is present but
liveActivityis missing; liveActivityis combined with an APNs entry inproviderOverrides;- a
startomitsattributesType,attributes, oralert, or setsstaleDateordismissalDate; - an
updatesets start fields,dismissalDate,inputPushToken, orinputPushChannel; - an
endsets start fields,staleDate,inputPushToken, orinputPushChannel; inputPushTokenandinputPushChannelare both set;lowPoweris used for direct (non-broadcast) delivery;- a broadcast recipient carries a
startevent.
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/publishContent-Type: application/jsonx-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" }}{ "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.
{ "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" }}{ "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
-
Create a channel through the signed, push-admin API:
POST /apps/{appId}/push/liveActivities/channelsContent-Type: application/json{"storagePolicy":"mostRecent"}201 Created { "channelId": "CHANNEL_ID", "storagePolicy": "mostRecent" } -
Store the returned
channelIdandstoragePolicywith the event it represents, and hand the channel ID to apps so they can start activities withinputPushChannel. -
Publish updates to the channel with an
apnsLiveActivityBroadcastrecipient (example below). -
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:
| Request | Response |
|---|---|
GET /apps/{appId}/push/liveActivities/channels | 200 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.
{ "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
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.
| Condition | Behavior |
|---|---|
| Payload too large | The 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 5xx | Retried with jitter and Retry-After. |
APNs 5xx | Holds 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 error | Terminal and observable, without leaking tokens. |
| Retried request | Reuses 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.