InvergeDocs
PHPAPI reference

Live Activities

Live Activities in the PHP SDK.

// access
$nexus->liveActivities()
SymbolKindSummary
LiveActivitiesclassLive Activities — a live, updating view of an in-progress event on the iOS Lock Screen / Dynamic Island and as an Android live notification.
LiveActivityBuilderclassFluent builder for a Live Activity.

LiveActivities

class
class Inverge\Nexus\Resource\LiveActivities

Live Activities — a live, updating view of an in-progress event on the iOS Lock Screen / Dynamic Island and as an Android live notification. This is the classic server-side use case: your backend starts an activity when an order / ride / match begins, updates it as the status changes, and ends it when done.

Templated (recommended) — design it once in the Nexus console; the mobile SDKs render it on iOS + Android in each device's language, and you send only data: $nexus->liveActivities()->template('order_tracking', 'order_42')->step('pending')->etaAt($eta)->value('driver', 'Ahmed')->toUser('u_1')->start(); then $nexus->liveActivities()->activity('order_42')->step('arrived')->update();

Plain (your own iOS widget): $nexus->liveActivities()->activity('DeliveryAttributes', 'order_42')->status('Preparing')->progress(20)->toUser('u_1')->start();

View source

__construct

constructor
function __construct(Inverge\Nexus\NexusClient $client)

Parameters

Prop

Type

View source

activity()

method
function activity(string $activityTypeOrId, ?string $activityId = NULL): Inverge\Nexus\LiveActivity\LiveActivityBuilder

Start a fluent Live Activity. Pass $activityType to start(); for update() / end() it may be omitted.

Parameters

Prop

Type

Returns Inverge\Nexus\LiveActivity\LiveActivityBuilder

View source

template()

method
function template(array|string $template, string $activityId): Inverge\Nexus\LiveActivity\LiveActivityBuilder

A templated activity: $template is a template key from the Nexus console (e.g. 'order_tracking') or an inline design array.

Parameters

Prop

Type

Returns Inverge\Nexus\LiveActivity\LiveActivityBuilder

View source

startTemplate()

method
function startTemplate(array|string $template, string $activityId, array $data = [], array $options = []): array

Start a templated activity. $data: step, state, progress (0–1), etaAt (unix seconds), values (for the template's {{placeholders}}). Each device gets its own language unless lang forces one.

Parameters

Prop

Type

Returns array<mixed> — { ios, android, iosTargets, iosWarning? }

View source

updateData()

method
function updateData(string $activityId, array $data, array $options = []): array

Update a templated activity with partial data — merged server-side (a null inside $data clears that field).

Parameters

Prop

Type

Returns array<mixed> — { ios, android }

View source

start()

method
function start(string $activityType, string $activityId, array $contentState, array $options = []): array

Start a live activity. Omit distinctIds for a shared activity (many users watching the same event); pass them to target specific users/orders.

Parameters

Prop

Type

Returns array<mixed> — { ios, android } — devices reached

View source

update()

method
function update(string $activityId, array $contentState, array $options = []): array

Push a new content state to every device on this activity. Use priority 5 for routine (unmetered) updates, 10 for immediate (metered).

Parameters

Prop

Type

Returns array<mixed> — { ios, android }

View source

end()

method
function end(string $activityId, array $options = []): array

End the activity. Optionally pass a final contentState (templated: final data, e.g. ['step' => 'completed']) and a dismissalDate (ISO-8601) controlling when iOS removes it.

Parameters

Prop

Type

Returns array<mixed> — { ios, android }

View source

registerPushToStartToken()

method
function registerPushToStartToken(string $activityType, string $token, array $options = []): array

Register an iOS push-to-start token (normally the client SDK does this).

Parameters

Prop

Type

Returns array<mixed>

View source

registerActivity()

method
function registerActivity(string $activityId, string $activityType, array $options = []): array

Register a running activity instance's update token (client-side; exposed for BYO integrations).

Parameters

Prop

Type

Returns array<mixed>

View source

event()

method
function event(string $activityId, string $type, array $options = []): array

Report a delivery receipt / click / failure for analytics.

Parameters

Prop

Type

Returns array<mixed>

View source

LiveActivityBuilder

class
class Inverge\Nexus\LiveActivity\LiveActivityBuilder

Fluent builder for a Live Activity. Compose the data / content-state and targeting, then start(), update(), or end().

Templated (recommended) — template-only setters (step, etaAt, value, canceled, …) send data, merged server-side on update:

$nexus->liveActivities()->template('order_tracking', 'order_42')
    ->step('pending')->etaAt(new DateTimeImmutable('+25 minutes'))
    ->values(['driver' => 'Ahmed'])->toUser('user_1')
    ->start();

$nexus->liveActivities()->activity('order_42')->step('arrived')->update();
$nexus->liveActivities()->activity('order_42')->step('completed')->end();

Plain (your own iOS widget) — progress() and the texts on their own keep sending a contentState:

$nexus->liveActivities()->activity('DeliveryAttributes', 'order_42')
    ->title('Order #42')->status('Preparing')->progress(20)
    ->toUsers(['user_1'])->priority(10)
    ->start();

$nexus->liveActivities()->activity('order_42')
    ->status('On the way')->progress(70)->priority(5)->update();

$nexus->liveActivities()->activity('order_42')->status('Delivered')->end();
View source

__construct

constructor
function __construct(Inverge\Nexus\NexusClient $client, string $activityId, ?string $activityType = NULL, array|string|null $template = NULL)

Parameters

Prop

Type

View source

step()

method
function step(string $step): self

The current step (a step id or label of the template). */

Parameters

Prop

Type

Returns self

View source

etaAt()

method
function etaAt(DateTimeInterface|int|float $at): self

Arrival time → a live countdown on the device (DateTime, unix seconds or ms). */

Parameters

Prop

Type

Returns self

View source

eta()

method
function eta(string $text): self

A fixed ETA text instead of a countdown, e.g. '8 min'. */

Parameters

Prop

Type

Returns self

View source

value()

method
function value(string $key, string|int|float|bool $value): self

One {{placeholder}} value. */

Parameters

Prop

Type

Returns self

View source

values()

method
function values(array $values): self

Parameters

Prop

Type

Returns self

View source

canceled()

method
function canceled(): self

Show the canceled state. */

Returns self

View source

done()

method
function done(): self

Show the finished state. */

Returns self

View source

data()

method
function data(array $data): self

Merge raw template data (step, state, progress, etaAt, values).

Parameters

Prop

Type

Returns self

View source

lang()

method
function lang(string $lang): self

Start only: force one language for every recipient (default: each device's own). */

Parameters

Prop

Type

Returns self

View source

alert()

method
function alert(string $title, ?string $body = NULL): self

Start only: the iOS alert shown with the start. */

Parameters

Prop

Type

Returns self

View source

title()

method
function title(string $v): self

Parameters

Prop

Type

Returns self

View source

subtitle()

method
function subtitle(string $v): self

Parameters

Prop

Type

Returns self

View source

body()

method
function body(string $v): self

Parameters

Prop

Type

Returns self

View source

status()

method
function status(string $v): self

Parameters

Prop

Type

Returns self

View source

progress()

method
function progress(int|float $v): self

Progress, 0.0–1.0 (or 0–100). Templated: toward the next step / along the bar. */

Parameters

Prop

Type

Returns self

View source

set()

method
function set(string $key, mixed $value): self

Set any content-state field. */

Parameters

Prop

Type

Returns self

View source

state()

method
function state(array $state): self

Merge multiple content-state fields.

Parameters

Prop

Type

Returns self

View source

toUsers()

method
function toUsers(array $distinctIds): self

Target specific users (per-user/order activity). Omit for a shared activity.

Parameters

Prop

Type

Returns self

View source

toUser()

method
function toUser(string $distinctId): self

Parameters

Prop

Type

Returns self

View source

shared()

method
function shared(): self

A shared activity — everyone who registered (a match, a launch, an incident). */

Returns self

View source

attributes()

method
function attributes(array $attributes): self

Fixed attributes set at start (iOS ActivityKit).

Parameters

Prop

Type

Returns self

View source

priority()

method
function priority(int $priority): self

APNs priority: 5 = routine (unmetered), 10 = immediate (metered). */

Parameters

Prop

Type

Returns self

View source

staleAt()

method
function staleAt(string $iso): self

ISO-8601 — mark the activity stale after this time. */

Parameters

Prop

Type

Returns self

View source

dismissAt()

method
function dismissAt(string $iso): self

ISO-8601 — when iOS should remove the activity (end only). */

Parameters

Prop

Type

Returns self

View source

start()

method
function start(): array

Start the activity.

Returns array<mixed> — { ios, android }

View source

update()

method
function update(): array

Push a new content-state.

Returns array<mixed> — { ios, android }

View source

end()

method
function end(): array

End the activity (with an optional final content-state and dismissal time).

Returns array<mixed> — { ios, android }

View source

On this page