Live Activities
Live Activities in the PHP SDK.
// access
$nexus->liveActivities()| Symbol | Kind | Summary |
|---|---|---|
LiveActivities | class | Live Activities — a live, updating view of an in-progress event on the iOS Lock Screen / Dynamic Island and as an Android live notification. |
LiveActivityBuilder | class | Fluent builder for a Live Activity. |
LiveActivities
classclass Inverge\Nexus\Resource\LiveActivitiesLive 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();
__construct
constructorfunction __construct(Inverge\Nexus\NexusClient $client)Parameters
Prop
Type
activity()
methodfunction activity(string $activityTypeOrId, ?string $activityId = NULL): Inverge\Nexus\LiveActivity\LiveActivityBuilderStart a fluent Live Activity. Pass $activityType to start(); for
update() / end() it may be omitted.
Parameters
Prop
Type
Returns Inverge\Nexus\LiveActivity\LiveActivityBuilder
template()
methodfunction template(array|string $template, string $activityId): Inverge\Nexus\LiveActivity\LiveActivityBuilderA 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
startTemplate()
methodfunction startTemplate(array|string $template, string $activityId, array $data = [], array $options = []): arrayStart 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? }
updateData()
methodfunction updateData(string $activityId, array $data, array $options = []): arrayUpdate a templated activity with partial data — merged server-side (a
null inside $data clears that field).
Parameters
Prop
Type
Returns array<mixed> — { ios, android }
start()
methodfunction start(string $activityType, string $activityId, array $contentState, array $options = []): arrayStart 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
update()
methodfunction update(string $activityId, array $contentState, array $options = []): arrayPush 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 }
end()
methodfunction end(string $activityId, array $options = []): arrayEnd 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 }
registerPushToStartToken()
methodfunction registerPushToStartToken(string $activityType, string $token, array $options = []): arrayRegister an iOS push-to-start token (normally the client SDK does this).
Parameters
Prop
Type
Returns array<mixed>
registerActivity()
methodfunction registerActivity(string $activityId, string $activityType, array $options = []): arrayRegister a running activity instance's update token (client-side; exposed for BYO integrations).
Parameters
Prop
Type
Returns array<mixed>
event()
methodfunction event(string $activityId, string $type, array $options = []): arrayReport a delivery receipt / click / failure for analytics.
Parameters
Prop
Type
Returns array<mixed>
LiveActivityBuilder
classclass Inverge\Nexus\LiveActivity\LiveActivityBuilderFluent 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();__construct
constructorfunction __construct(Inverge\Nexus\NexusClient $client, string $activityId, ?string $activityType = NULL, array|string|null $template = NULL)Parameters
Prop
Type
step()
methodfunction step(string $step): selfThe current step (a step id or label of the template). */
Parameters
Prop
Type
Returns self
etaAt()
methodfunction etaAt(DateTimeInterface|int|float $at): selfArrival time → a live countdown on the device (DateTime, unix seconds or ms). */
Parameters
Prop
Type
Returns self
eta()
methodfunction eta(string $text): selfA fixed ETA text instead of a countdown, e.g. '8 min'. */
Parameters
Prop
Type
Returns self
value()
methodfunction value(string $key, string|int|float|bool $value): selfOne {{placeholder}} value. */
Parameters
Prop
Type
Returns self
values()
methodfunction values(array $values): selfParameters
Prop
Type
Returns self
canceled()
methodfunction canceled(): selfShow the canceled state. */
Returns self
done()
methodfunction done(): selfShow the finished state. */
Returns self
data()
methodfunction data(array $data): selfMerge raw template data (step, state, progress, etaAt, values).
Parameters
Prop
Type
Returns self
lang()
methodfunction lang(string $lang): selfStart only: force one language for every recipient (default: each device's own). */
Parameters
Prop
Type
Returns self
alert()
methodfunction alert(string $title, ?string $body = NULL): selfStart only: the iOS alert shown with the start. */
Parameters
Prop
Type
Returns self
title()
methodfunction title(string $v): selfParameters
Prop
Type
Returns self
subtitle()
methodfunction subtitle(string $v): selfParameters
Prop
Type
Returns self
body()
methodfunction body(string $v): selfParameters
Prop
Type
Returns self
status()
methodfunction status(string $v): selfParameters
Prop
Type
Returns self
progress()
methodfunction progress(int|float $v): selfProgress, 0.0–1.0 (or 0–100). Templated: toward the next step / along the bar. */
Parameters
Prop
Type
Returns self
set()
methodfunction set(string $key, mixed $value): selfSet any content-state field. */
Parameters
Prop
Type
Returns self
state()
methodfunction state(array $state): selfMerge multiple content-state fields.
Parameters
Prop
Type
Returns self
toUsers()
methodfunction toUsers(array $distinctIds): selfTarget specific users (per-user/order activity). Omit for a shared activity.
Parameters
Prop
Type
Returns self
toUser()
methodfunction toUser(string $distinctId): selfParameters
Prop
Type
Returns self
shared()
methodfunction shared(): selfA shared activity — everyone who registered (a match, a launch, an incident). */
Returns self
attributes()
methodfunction attributes(array $attributes): selfFixed attributes set at start (iOS ActivityKit).
Parameters
Prop
Type
Returns self
priority()
methodfunction priority(int $priority): selfAPNs priority: 5 = routine (unmetered), 10 = immediate (metered). */
Parameters
Prop
Type
Returns self
staleAt()
methodfunction staleAt(string $iso): selfISO-8601 — mark the activity stale after this time. */
Parameters
Prop
Type
Returns self
dismissAt()
methodfunction dismissAt(string $iso): selfISO-8601 — when iOS should remove the activity (end only). */
Parameters
Prop
Type
Returns self
start()
methodfunction start(): arrayStart the activity.
Returns array<mixed> — { ios, android }
update()
methodfunction update(): arrayPush a new content-state.
Returns array<mixed> — { ios, android }
end()
methodfunction end(): arrayEnd the activity (with an optional final content-state and dismissal time).
Returns array<mixed> — { ios, android }
