InvergeDocs
JavaScriptAPI reference

Live Activities

Live Activities in the JavaScript SDK.

// access
nexus.liveActivities
SymbolKindSummary
NexusLiveActivitiesclassLive Activities — a live, updating view of an in-progress event on the iOS Lock Screen / Dynamic Island and as an Android live notification.
NexusLiveActivityBuilderclassFluent builder for a Live Activity.
LiveActivityResultinterface
LiveActivityDatainterfaceData for a templated Live Activity (the design lives in a template made in the Nexus console, or sent inline).
LiveActivityTemplateStartOptionsinterface

NexusLiveActivities

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. The classic server-side use case: start when the event begins, update as it changes, end when it's done.

Templated (recommended) — design in the Nexus console, send only data; the SDKs render it on iOS + Android in each device's language: 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().

NexusLiveActivities

constructor
new NexusLiveActivities(http: NexusHttp, id: NexusIdentity)

Parameters

Prop

Type

Returns NexusLiveActivities

View source

activity()

method
activity(activityTypeOrId: string, activityId?: string): NexusLiveActivityBuilder

Start a fluent Live Activity. activity(type, id) for start; activity(id) for update/end.

Parameters

Prop

Type

Returns NexusLiveActivityBuilder

View source

template()

method
template(template: string | Record<string, unknown>, activityId: string): NexusLiveActivityBuilder

A templated activity: template is a template key from the console (e.g. "order_tracking") or an inline design object.

Parameters

Prop

Type

Returns NexusLiveActivityBuilder

View source

startTemplate()

method
async startTemplate(template: string | Record<string, unknown>, activityId: string, data: LiveActivityData = {}, options: LiveActivityTemplateStartOptions = {}): Promise<LiveActivityResult>

Start a templated activity (plain form).

Parameters

Prop

Type

Returns Promise<LiveActivityResult>

View source

updateData()

method
async updateData(activityId: string, data: LiveActivityData, options: { staleDate?: string; priority?: number } = {}): Promise<LiveActivityResult>

Update a templated activity with partial data (merged server-side).

Parameters

Prop

Type

Returns Promise<LiveActivityResult>

View source

start()

method
async start(activityType: string, activityId: string, contentState: Record<string, unknown>, options: { distinctIds?: string[]; attributes?: Record<string, unknown>; staleDate?: string; priority?: number } = {}): Promise<LiveActivityResult>

Start an activity (plain form). Omit distinctIds for a shared activity.

Parameters

Prop

Type

Returns Promise<LiveActivityResult>

View source

update()

method
async update(activityId: string, contentState: Record<string, unknown>, options: { staleDate?: string; priority?: number } = {}): Promise<LiveActivityResult>

Parameters

Prop

Type

Returns Promise<LiveActivityResult>

View source

end()

method
async end(activityId: string, options: { contentState?: Record<string, unknown>; data?: LiveActivityData; dismissalDate?: string } = {}): Promise<LiveActivityResult>

End an activity. Templated: data is the final state shown before dismissal (e.g. { step: 'completed' }).

Parameters

Prop

Type

Returns Promise<LiveActivityResult>

View source

registerPushToStartToken()

method
async registerPushToStartToken(activityType: string, token: string): Promise<void>

Register an iOS push-to-start token (client-side; exposed for BYO).

Parameters

Prop

Type

View source

registerActivity()

method
async registerActivity(activityId: string, activityType: string, options: { platform?: string; updateToken?: string; contentState?: Record<string, unknown> } = {}): Promise<void>

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

Parameters

Prop

Type

View source

event()

method
async event(activityId: string, type: 'receipt' | 'click' | 'failed', options: { platform?: string } = {}): Promise<void>

Report a receipt / click / failure for analytics.

Parameters

Prop

Type

View source

NexusLiveActivityBuilder

class

Fluent builder for a Live Activity. Template data setters (step, etaAt, value, canceled, …) send data; the plain setters (status, set, …) send a contentState for your own widget.

NexusLiveActivityBuilder

constructor
new NexusLiveActivityBuilder(http: NexusHttp, activityId: string, activityType?: string, _template?: string | Record<string, unknown>)

Parameters

Prop

Type

Returns NexusLiveActivityBuilder

View source

step()

method
step(step: string): this

Current step (a step id or label of the template).

Parameters

Prop

Type

Returns this

View source

etaAt()

method
etaAt(at: Date | number): this

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

Parameters

Prop

Type

Returns this

View source

eta()

method
eta(text: string): this

A fixed ETA text instead of a countdown, e.g. "8 min" (the eta value).

Parameters

Prop

Type

Returns this

View source

value()

method
value(key: string, value: string | number | boolean): this

One {{placeholder}} value.

Parameters

Prop

Type

Returns this

View source

values()

method
values(values: Record<string, string | number | boolean>): this

Parameters

Prop

Type

Returns this

View source

canceled()

method
canceled(): this

Show the canceled state.

Returns this

View source

done()

method
done(): this

Show the finished state.

Returns this

View source

data()

method
data(data: LiveActivityData): this

Partial template data (merged).

Parameters

Prop

Type

Returns this

View source

lang()

method
lang(lang: string): this

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

Parameters

Prop

Type

Returns this

View source

alert()

method
alert(title: string, body?: string): this

Start only: the iOS alert shown with the start.

Parameters

Prop

Type

Returns this

View source

title()

method
title(v: string): this

Parameters

Prop

Type

Returns this

View source

subtitle()

method
subtitle(v: string): this

Parameters

Prop

Type

Returns this

View source

body()

method
body(v: string): this

Parameters

Prop

Type

Returns this

View source

status()

method
status(v: string): this

Parameters

Prop

Type

Returns this

View source

progress()

method
progress(v: number): this

Progress 0–1 (or 0–100). Templated: toward the next step / along the bar.

Parameters

Prop

Type

Returns this

View source

set()

method
set(key: string, value: unknown): this

Parameters

Prop

Type

Returns this

View source

state()

method
state(state: Record<string, unknown>): this

Parameters

Prop

Type

Returns this

View source

toUsers()

method
toUsers(distinctIds: string[]): this

Parameters

Prop

Type

Returns this

View source

toUser()

method
toUser(distinctId: string): this

Parameters

Prop

Type

Returns this

View source

shared()

method
shared(): this

A shared activity (many users watching one event).

Returns this

View source

attributes()

method
attributes(attributes: Record<string, unknown>): this

Parameters

Prop

Type

Returns this

View source

priority()

method
priority(priority: number): this

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

Parameters

Prop

Type

Returns this

View source

staleAt()

method
staleAt(iso: string): this

Parameters

Prop

Type

Returns this

View source

dismissAt()

method
dismissAt(iso: string): this

Parameters

Prop

Type

Returns this

View source

start()

method
async start(): Promise<LiveActivityResult>

Returns Promise<LiveActivityResult>

View source

update()

method
async update(): Promise<LiveActivityResult>

Returns Promise<LiveActivityResult>

View source

end()

method
async end(): Promise<LiveActivityResult>

Returns Promise<LiveActivityResult>

View source

LiveActivityResult

interface

ios

property
ios: number

android

property
android: number

iosTargets

property
iosTargets?: number

Start only: iOS devices registered for the activity type.

iosWarning

property
iosWarning?: string

Start only: why iOS got fewer deliveries than targets (no devices, APNs not set up, Apple's error).

LiveActivityData

interface

Data for a templated Live Activity (the design lives in a template made in the Nexus console, or sent inline). On update, send only what changed — the server merges it into the current data (null clears a field).

step

property
step?: string | null

Current step id (or label) of a steps template, e.g. "on_the_way".

state

property
state?: 'active' | 'canceled' | 'done' | (string & {}) | null

"active" | "canceled" | "done".

progress

property
progress?: number | null

0–1: the tracker's position toward the next step (or along the bar).

etaAt

property
etaAt?: number | null

Arrival time, unix seconds — a live countdown on the device.

values

property
values?: Record<string, string | number | boolean | null>

Values for the template's {{placeholders}}; eta shows as fixed ETA text.

title

property
title?: string | null

Override the template's texts for this activity.

subtitle

property
subtitle?: string | null

body

property
body?: string | null

LiveActivityTemplateStartOptions

interface

distinctIds

property
distinctIds?: string[]

Omit for a shared activity (everyone).

lang

property
lang?: string

Force one language for every recipient (default: each device's app language).

alert

property
alert?: { title: string; body?: string }

iOS alert shown with the start (default: the template's current texts).

attributes

property
attributes?: Record<string, unknown>

staleDate

property
staleDate?: string

priority

property
priority?: number

On this page