Skip to main content

Crate baukit_push

Crate baukit_push 

Source
Expand description

Provider-neutral push delivery with an Expo adapter.

The crate separates a small PushSender port from its ExpoPushSender adapter. Domain code builds PushMessage values and reads PushOutcome values; nothing above the port names a provider. Scheduling, quiet hours, and deciding who gets notified stay in the product.

§Two-phase delivery

Expo answers a send with a ticket per notification, then confirms delivery later through a receipt. ExpoPushSender runs both phases per batch, so one call returns PushDeliveryStatus::Delivered or PushDeliveryStatus::Rejected wherever Expo has settled, and PushDeliveryStatus::Accepted where it has not. Never resend on Accepted; the notification is in flight.

§Pruning dead tokens

A device token stops working once the app is uninstalled. Expo reports that as DeviceNotRegistered, which becomes PushRejection::DeviceNotRegistered. Delete those tokens after every send, or the same failures repeat forever:

use baukit_push::{PushOutcome, PushSender};

async fn deliver(
    sender: &impl PushSender,
    messages: Vec<baukit_push::PushMessage>,
) -> Result<Vec<String>, baukit_push::PushError> {
    let outcomes = sender.send(messages).await?;
    Ok(outcomes
        .iter()
        .filter(|outcome| PushOutcome::is_token_dead(outcome))
        .map(|outcome| outcome.token.clone())
        .collect())
}

§Retries

Whole-request failures arrive as PushError::Transport carrying a baukit_http::RetryClass, so an Expo rate limit with a Retry-After header reaches the caller as a concrete delay through PushError::retry_after. Per-notification refusals are not errors: inspect PushRejection::is_retryable on each outcome instead.

Structs§

ExpoPushSender
Expo push adapter.
PushConfig
Deserializable push configuration for a product’s config section.
PushMessage
One notification addressed to a single device token.
PushOptions
Validated options an ExpoPushSender is built from.
PushOutcome
What happened to one notification, keyed by the token it was addressed to.

Enums§

PushDeliveryStatus
The delivery state a provider reported for one notification.
PushError
A failure that prevented the whole batch from being processed.
PushOptionsError
Invalid push adapter configuration.
PushRejection
Why a provider rejected one notification.

Constants§

DEFAULT_EXPO_ENDPOINT
Expo’s public push send endpoint.
MAX_BATCH_SIZE
Largest batch Expo accepts in one /push/send request.

Traits§

PushSender
Outbound port for delivering notifications to devices.

Type Aliases§

PushFuture
The future returned by PushSender::send.