Skip to content
Agentpost robot in sunglasses on a red circleAgentpost

Push

A push brings a notification to a principal’s phone, beside their inbox. Each phone is a push address: the token your app got from Expo, bound to one recipient. When a notification is made for a recipient whose preference lets its topic reach push, EventWolf sends one push to each of their addresses, as a delivery of kind push, and keeps every attempt.

Push addresses

A push address is a provider, expo, and a token, such as ExponentPushToken[…] from getExpoPushTokenAsync, bound to one recipient. No answer holds the token. EventWolf sends through Expo, so set provider to expo; another provider answers push_unavailable.

Your app ties each address to the principal’s session:

  • At sign-in, register the phone’s token for the principal, and keep the address id you get back beside their session.
  • When the app opens, mark the phone seen, as Each phone’s badge says.
  • At sign-out, remove the address by that id. Removing it cancels the pushes still waiting to go to it. A server that kept the token instead removes the address by its provider and token.

Your server does this with the secret key. A signed-in principal can do it for their own addresses, and no one else’s, with their user token.

A token belongs to one recipient at a time in a project, so a shared phone’s pushes follow the recipient who registered its token last; only a push already in flight when the token moves can still arrive:

  • Registering a token another recipient holds moves it to the newcomer, under a new address id. Pushes still waiting to go to the old address are canceled, and removing the old id, as a late sign-out does, leaves the newcomer’s address alone.
  • Registering a token the recipient already holds answers with the same address with its seen position intact, made active again if it was invalid.
  • Another project’s addresses are its own. The same token in two projects is two addresses, and moving or invalidating one never touches the other.

Deleting a recipient removes their push addresses too, and cancels the pushes still waiting to go to them. The text of every push to those addresses is removed, sent or not.

What a push carries

  • Lock-screen text: the subscription template’s push text, which can be shorter and less revealing than the inbox’s. With push set, its title falls back to the inbox title, and the inbox body never reaches the lock screen. Without it, the push shows the inbox title and body. The text is made once, when the event is accepted, and erasure scrubs it.
  • data: { notificationId, url }, the notification’s ID and its rendered url when it has one, so your app opens the right screen when a human taps the push, and can mark the notification read or seen.
  • A sound: the device’s default sound, unless the template’s push.sound names one your app bundles, or is null for a silent push.
  • A badge: the recipient’s delivered, non-archived notifications newer than this address’s seen position. Each phone keeps its own position. Set the config’s push.badge to false to send pushes with no badge and keep the app icon’s badge in your app.

Push and the inbox are decided apart, topic by topic: a topic’s defaults.push says whether a principal who hasn’t chosen gets a push, a principal’s preference overrides it, and a required topic reaches both. A push goes out even when the principal turned the inbox off for that topic. Its notification is then skipped in the inbox, so it isn’t in the badge and the app can’t mark it read. The app can still mark the phone seen through it.

Each phone’s badge

A new address starts with nothing seen, including notifications delivered before it was registered. Registering a held token for another recipient creates a new address with no seen position. Reading a notification does not clear its badge count; archiving it removes it from every phone’s count.

When your app opens, call Mark a push address seen, POST /push-addresses/{id}/seen with { through: notificationId }, through the newest delivered notification shown on that phone. Use the address ID kept at registration. With the SDK, call client.pushAddresses.seen(addressId, notificationId) from your backend, or inbox.seenOnPushAddress(addressId, notificationId) with the principal’s user token. If the inbox is empty, there is no position to mark.

The answer gives the stored seenThrough and the phone’s remaining unseen count. Use that count for the app’s local badge. The position only moves forward. A late call with an older notification that is still stored answers with the newer position. Marking a phone seen affects just that address. Marking the inbox seen affects just the inbox. Each project’s addresses keep separate positions even when they hold the same token.

When the badge can’t be counted, the push goes without one.

How a push is delivered

EventWolf queues the push for immediate send. Expo accepts it with its own ID for the push, the attempt’s providerMessageId, or refuses it. An accepted push stays pending while EventWolf waits for a receipt. EventWolf first checks after 15 minutes, then checks again every 15 minutes while it waits. A successful receipt confirms handoff to Apple’s or Google’s push service and makes the delivery succeeded. Expo’s push receipts describes a receipt.

Sends to one address run one at a time across dispatcher processes. Each time a send slot opens, EventWolf picks the oldest notification among pushes that are due. Other addresses and projects can use other slots while that address’s provider call is slow. Waiting for Expo’s receipt holds no send slot.

A send Expo couldn’t take, because the call failed as a whole or Expo rate-limited it, is tried again on the config’s push.retrySchedule: in Agentpost’s starting config after 30 seconds, 5 minutes, and 30 minutes. Any other refusal fails the delivery. Backoff holds no send slot: fresh alerts go out meanwhile, so a push retried on the schedule or by hand can arrive after a newer one. When badges are on, each send takes a fresh count if counting succeeds. Each attempt shows the provider as its target and includes providerMessageId if Expo accepted it. A failed send has push_send_failed unless the token was reported as unregistered. An accepted attempt is succeeded; a failed or missing receipt changes it to failed with push_delivery_failed, unless the receipt names an unregistered token.

When Expo reports DeviceNotRegistered at send time or in the receipt, that token can’t receive pushes:

  • The attempt is failed with device_not_registered, and so is the delivery.
  • The address becomes invalid, and tools.agentpost.events.push_address.invalidated lands in your event stream with the address and recipient.
  • Later pushes to it are recorded as skipped with address_invalid, until the app registers the token again.

A refusal that can’t be retried, a send that runs out of retries, or an accepted push with no receipt by the end of polling fails the delivery and emits tools.agentpost.events.delivery.exhausted with kind: "push". DeviceNotRegistered follows the invalidation path above. A push waiting for an address that was removed is canceled. A push still waiting to send when its event is erased is skipped with event_erased. List a project’s pushes with kind=push on List deliveries, or one phone’s with pushAddressId.

Expo access token

When your Expo project turns on enhanced push security, Expo accepts pushes only with your Expo access token. Put it in the config’s push.expo.accessToken with Update the config. EventWolf stores the token encrypted and shows only hasAccessToken. Omitting the token keeps the stored one, and null removes it.

Limits

  • A push title is at most 200 characters and a body 1,000. Inbox text used on the lock screen is cut to these.
  • A token is at most 500 characters.
  • A failed send that can be retried gets up to 19 scheduled retries, as set by push.retrySchedule. Agentpost starts projects with 3.
  • EventWolf first checks for an Expo receipt 15 minutes after sending and stops retrying the check after the 24-hour receipt window.
  • Push deliveries and their attempts are kept for the config’s retention.deliveries, as webhooks’ are.

Where to act on it