com.allternit.mobile) gets the same notifications as Web Push: rings, missed calls, thread messages, channel messages, and every backbone event the person is notified about. cloud-api sends each one to Apple Push Notification service (APNs) as well as to the browser subscriptions. Notification preferences, quiet hours, the per-thread collapse and the hourly cap are applied once, before either transport, so the phone and the browser always agree.
It is off until the APNs key below is set. With it unset, the token routes answer 503 {"error":"apns_not_configured"} and nothing is sent. The push pipeline itself is switched on by the Web Push VAPID keys, so both sets must be present for iPhones to get pushes. Migration 111_apns_device_tokens.sql adds the token table and 120_ios_system_surfaces.sql adds the device details, activity tokens, the read token and status snapshots. The Contabo deploy (cmd/allternit-cloud-api/deploy-contabo.sh) applies each file that is not yet listed in ops_applied_migrations, before it swaps the binary.
Turn it on
Android uses the same routes with
platform: "android" and an FCM registration token. See Android (FCM) below..p8 file once (Apple doesn’t let you download it again). Then set these on allternit-cloud-api:
One token-auth key works for every app in the team and for both the sandbox and production gateways. cloud-api signs an ES256 provider token with it and reuses that token for 40 minutes (Apple rejects tokens older than an hour and refreshing more than every 20 minutes).
Routes
The device token and activity token routes take a Clerk session or acompute-scoped API key. The app calls cloud-api directly, never through the runtime relay.
POST /api/v1/device-tokens:
201 {"ok": true, "id": "apns_…", "readToken": "adr_…"}. osVersion, appBuild and capabilities are optional; an app that sends none is registered with no capabilities and gets the plain alert. capabilities says what this build of the app can handle:
Other values are dropped.
readToken is new on every registration (the old one stops working) and is shown only once: cloud-api stores only its hash. The app keeps it in the shared keychain for its extensions and uses it on the device read routes only. environment is sandbox for debug builds and production for TestFlight and App Store builds; the push goes to the matching APNs host. deviceId is the app’s identifierForVendor, so a reinstall replaces the old token. A token belongs to one person: registering it while signed in as someone else moves it. A person may register 10 iPhones. Errors: 400 bad_token | unsupported_platform, 429 too_many_devices.
-
DELETE /api/v1/device-tokenswith{"token": "a1b2…"}returns{"ok": true, "removed": true}. It also removes that device’s activity tokens. The app calls it on sign-out, before the session ends. -
PUT /api/v1/device-tokens/activitysaves a Live Activity or widget push token for a registered device:
201 {"ok": true, "id": "apat_…"}. kind is la_start (the push-to-start token for one attributes type), la_update (the update token of one running activity, named by activityKey) or widget (the widget push token). A newer token replaces the older one of the same device and kind (and the same attributesType or activityKey). Errors: 400 bad_kind | bad_token | device_id_required, 404 unknown_device when deviceId has no device token for this person, 429 too_many_tokens (40 per person).
DELETE /api/v1/device-tokens/activitywith{"token": "…"}returns{"ok": true, "removed": true}.
410, BadDeviceToken, Unregistered or DeviceTokenNotForTopic deletes the token. Other failures are counted, and a token is removed after 8 in a row. 403 ExpiredProviderToken makes cloud-api sign a new provider token.
Android (FCM)
The native Android app (surfaces/allternit-mobile/android/feature/push) registers its Firebase Cloud Messaging token on the same route:
A–Z a–z 0–9 _ - :. environment is ignored. Android and iOS share the 10-device cap and the apns_device_tokens table (column platform, migration 152_device_token_platform.sql); APNs never sends to an Android row and FCM never sends to an iOS row. Without FCM configured the route answers 503 fcm_not_configured.
Turn it on. Set FCM_SERVICE_ACCOUNT_JSON on allternit-cloud-api to the Firebase service account key for project allternit-6b8e1 (the JSON itself, or a path to the file). cloud-api signs an RS256 JWT with it, trades it for an OAuth2 access token (firebase.messaging scope, cached until five minutes before it expires) and posts to https://fcm.googleapis.com/v1/projects/<project>/messages:send. With the variable unset, Android sends are skipped with one warning in the log; nothing fails.
Payload. Every sender that reaches APNs reaches FCM too (src/routes/fcm.rs). The message is data-only, so the app builds the notification: string keys type, title, body, url, tag, event, category, level, botId, inboxId, sessionId, runtimeId, contentHash, private, and data (the whole data object as JSON). android.priority is HIGH for calls and needs-you alerts, else NORMAL; collapse_key is the tag. A gone token (404, UNREGISTERED, SENDER_ID_MISMATCH) is deleted; eight failures in a row drop it. A revoke is { "event": "notification.revoke", "tags": "approval-ap1,…" } and removes those notifications.
Client config. The app has no google-services plugin and no Firebase file in git. The nativeapp build turns the local client config (~/.config/allternit/firebase/google-services.json, or ALLTERNIT_FIREBASE_CONFIG, or the ALLTERNIT_FIREBASE_APP_ID / _API_KEY / _SENDER_ID / _PROJECT_ID gradle properties) into the string resources Firebase reads at start. A build without it runs with push off.
Device read routes
The notification service extension and the widgets run without the app’s Clerk session. They call these two routes withAuthorization: Bearer <readToken>. Both also take the normal Clerk session. The read token is refused (401) on every other route, and it only reads its own person’s data.
GET /api/v1/status/summaryreturns the latest status snapshot of each of the person’s computers, newest first, or an empty list:
GET /api/v1/notifications/content/{eventId}returns the text of one notification, built the same way as the push:
404 not_found for an unknown id, another person’s event, or an event that is never shown as a notification. sender.avatarUrl is filled only when the computer’s event carries an https avatar URL. sender.avatarUrl is also read from the event’s botAvatar; cloud keeps no bot record of its own. communication is true only for a bot’s direct reply (message.received with senderKind: "bot"). It is the server-side switch for iOS communication notifications (the bot shown as the sender, labelled as an assistant).
A read token that is malformed, replaced by a newer registration, or belongs to an unregistered device gets 401 {"error":"invalid_read_token"}.
Server: cmd/allternit-cloud-api/src/routes/device_read.rs.
Other push types
apns::send_raw sends any APNs push type to one token: background to a device token, liveactivity to an activity token (topic com.allternit.mobile.push-type.liveactivity), widgets to a widget token (topic com.allternit.mobile.push-type.widgets). It uses the same provider token and the same cleanup as alerts: a gone device token also takes that device’s activity tokens with it. When cloud sends liveactivity and widgets pushes is in Live Activity pushes and Widget pushes.
Payload
Each iPhone gets its own alert. It is built from the same message as the Web Push and shaped by what that app said it supports at registration (capabilities):
type, url, tag and data are the same as in the Web Push payload. The data keys are listed under data keys. tag is also sent as apns-collapse-id (first 64 bytes), so the phone keeps only the latest of each; a push for an inbox item uses the item as its tag. Calls, urgent pages and needs-you pushes go out at apns-priority: 10, everything else at 5. apns-expiration follows the message’s TTL. The server keeps no unread count, so badge is 1 and the app clears it when opened. Each alert logs one line (apns alert to <row id>: event=… category=… interruption-level=… mutable-content=… private=…), never the text.
Coding-session permission asks (source: "gizzi-permission") come to the iPhone through this path only. Browsers get them from the gizzi remote-control lane.
Factory approvals (inboxKind: "factory_approval", or any approval.requested carrying surfaces) that the runtime already pushed itself (surfaces holds "push": its Remote Control Web Push, with the one-time approve code, reached at least one device) get the iPhone app push only from cloud, so a browser never gets two. When the runtime’s push isn’t set up (no push worker URL, not paired to the owner, no runtime id) or reached no device, surfaces has no "push" and cloud sends its Web Push as usual. The two Web Push paths keep separate subscription lists, so a browser subscribed only to cloud’s Web Push, while another device took the runtime’s push, gets the approval in the app inbox and the iPhone app but no Web Push.
One notification per iPhone. A Web Push subscription with platform: "ios-pwa" is skipped while the same person has an iPhone registered here. A phone with both the app and the home-screen app gets the app’s notification only.
Live Activity pushes
After a changed status snapshot is stored, cloud merges the person’s fresh snapshots (one per runtime, at most 12 hours old) and decides, per device, what to send to its activity tokens. Devices without thela_push capability get none. Every push is apns-push-type: liveactivity, topic com.allternit.mobile.push-type.liveactivity, under 4 KB (the step is cut first).
Tokens the app uploads (PUT /api/v1/device-tokens/activity):
Bot activity content state (
BotActivityAttributes.ContentState). The six fields the app has, always: status, activityLabel, pendingApprovalsCount, activeBotsCount, attentionBotsCount, displayName (the focus bot’s name). Optional, left out when absent: botId, step, progress (0 to 1), othersCount (other active bots), question, inboxId, runtimeId, sessionId, contentHash, approveInline. No Date values. The focus is the snapshot focus that matters most across runtimes: an approval, then a question, then a blocked or failed bot, then work.
question, contentHash and approveInline: true ride only when the focus has approveInline: true, private is not true, a contentHash is present and the question is 140 characters or fewer. Otherwise question is a generic line (“Needs your approval”, or “Needs your input” for an attention item) with no hash, and the phone shows Open only. Live Activity pushes are not encrypted, so private text never rides in them, in the content state or the alert.
Working:
"question":"Needs your approval", no contentHash, no approveInline, and the alert body “Needs your approval”.
When each event goes out
start(to thela_starttoken, priority 10) carries"attributes-type":"BotActivityAttributes","attributes":{"mode":"summary"},"input-push-token":1and an alert withsound. Only on idle to active (the merged snapshots had no active bot, attention or pending approval, and now do), at most once per 10 minutes per device, never while quiet hours hold the level (work is low, an approval is needs-you; default quiet hours hold both), and only when the device has nola_updatetoken for the bot activity.updateat priority 5 for progress, at least 15 seconds apart per device. A change inside the window is kept and sent when the window ends, the latest state winning. When the state becomes needs-approval (or a new item becomes the focus), priority 10 with an alert at once; while quiet hours hold it, no alert.end(priority 10) with the final state anddismissal-date15 minutes ahead when the merged snapshots go idle. Close to 8 hours (7 h 30 min after the update token arrived) cloud ends the activity with an immediatedismissal-date, and the next change starts a new one. Cloud removes an update token once APNs accepts itsend.startandupdatecarrystale-dateone hour ahead (the runtime only sends a snapshot when something changes). A Focus filter that mutes the focus bot drops the alert’ssound.
LoopActivityAttributes.ContentState: iterationsCompleted, maxIterations, state) follow snapshot.loops by loopId: update (priority 5, 15 seconds apart) on a change, end when the loop’s state is no longer running, pending, starting or paused, or when the loop is gone from snapshots that all carry loops (ended as stopped). A snapshot without loops (the runtime’s loop poll failed) ends nothing.
Bar job activities (TaskActivityAttributes.ContentState: state and isOwner always; approverName, botName, amount, receipt, error; for the approver while the job waits, inboxId and, when the ask may be answered inline, question, contentHash, approveInline, runtimeId) follow the runtime’s bar_job.changed event, sent for the requester and the approver. start (priority 10, with an alert for the approver) when a job is waiting_approval or working and the phone has no update token for the jobId yet; update on every later state; end on completed, failed or cancelled (kept four hours) and, for the approver, as soon as the job stops waiting.
Throttle state. Each “last sent” time is the later of an in-memory map (every attempt) and the token row’s last_ok_at (every push APNs accepted). After a restart the database times still hold the start, update and widget limits; only a coalesced update waiting for its window is lost, and the next snapshot carries the newer state. Each push logs one line, live activity push: liveactivity <event> to <token row> (device …, <attributes>) priority=… alert=… bytes=…, never the text.
Widget pushes
When what the widget shows changes (the counts,needsYouRows, paused, lastRoutine), cloud sends {"aps":{"content-changed":true}} with apns-push-type: widgets, topic com.allternit.mobile.push-type.widgets, priority 5, to each widget token of a device with the widget_push capability. At most one per 5 minutes per device; a change inside the window is sent when it ends. A new step or progress is not a widget change. Widget pushes need iOS 26.
Server: cmd/allternit-cloud-api/src/routes/live_activity.rs.
Revoke
When an inbox item leaves the runtime’sneedsYou list (status snapshots), cloud sends every iPhone of that person a background push (apns-push-type: background, apns-priority: 5):
notification_delivered).
In the app
- Permission is asked with a reason on screen, never on first launch: in the Meet your bots intro’s notifications step, on the empty-chat card, or in Settings → Getting started → Notifications. After that, every launch and every sign-in registers again without asking.
- Tapping a notification opens its
url: a thread opens its current chat (or the bot’s page when the thread has no live session), a channel message opens the bots,/settings/…opens Settings,/computersopens the computers list. An approval (data.eventapproval.requested) opens Decisions, where it can be answered, instead of itsurl. - The app also opens Universal Links to the same screens.
surfaces/allternit-mobile/ios/Core/PushNotificationManager.swift, App/AppDelegate.swift, Core/API/PushTokenClient.swift, Core/DeepLinkRouter.swift. Server: cmd/allternit-cloud-api/src/routes/apns.rs, called from web_push::send_to_user.
Universal Links
https://ai.allternit.com and https://m.allternit.com serve /.well-known/apple-app-site-association (allternit-ai public/.well-known/, copied into the PWA build by scripts/prepare-fabric-session-pwa.mjs, served as application/json). With the app installed, these open in it:
The app needs the
applinks:ai.allternit.com and applinks:m.allternit.com associated domains, and the file’s appIDs must carry the real team id (<TEAMID>.com.allternit.mobile).