Live Activities
Live Activities in the JavaScript SDK.
// access
nexus.liveActivities| Symbol | Kind | Summary |
|---|---|---|
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. |
NexusLiveActivityBuilder | class | Fluent builder for a Live Activity. |
LiveActivityResult | interface | |
LiveActivityData | interface | Data for a templated Live Activity (the design lives in a template made in the Nexus console, or sent inline). |
LiveActivityTemplateStartOptions | interface |
NexusLiveActivities
classLive 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
constructornew NexusLiveActivities(http: NexusHttp, id: NexusIdentity)Parameters
Prop
Type
Returns NexusLiveActivities
activity()
methodactivity(activityTypeOrId: string, activityId?: string): NexusLiveActivityBuilderStart a fluent Live Activity. activity(type, id) for start; activity(id) for update/end.
Parameters
Prop
Type
Returns NexusLiveActivityBuilder
template()
methodtemplate(template: string | Record<string, unknown>, activityId: string): NexusLiveActivityBuilderA templated activity: template is a template key from the console (e.g.
"order_tracking") or an inline design object.
Parameters
Prop
Type
Returns NexusLiveActivityBuilder
startTemplate()
methodasync 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>
updateData()
methodasync 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>
start()
methodasync 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>
update()
methodasync update(activityId: string, contentState: Record<string, unknown>, options: { staleDate?: string; priority?: number } = {}): Promise<LiveActivityResult>Parameters
Prop
Type
Returns Promise<LiveActivityResult>
end()
methodasync 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>
registerPushToStartToken()
methodasync registerPushToStartToken(activityType: string, token: string): Promise<void>Register an iOS push-to-start token (client-side; exposed for BYO).
Parameters
Prop
Type
registerActivity()
methodasync 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
event()
methodasync event(activityId: string, type: 'receipt' | 'click' | 'failed', options: { platform?: string } = {}): Promise<void>Report a receipt / click / failure for analytics.
Parameters
Prop
Type
NexusLiveActivityBuilder
classFluent 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
constructornew NexusLiveActivityBuilder(http: NexusHttp, activityId: string, activityType?: string, _template?: string | Record<string, unknown>)Parameters
Prop
Type
Returns NexusLiveActivityBuilder
step()
methodstep(step: string): thisCurrent step (a step id or label of the template).
Parameters
Prop
Type
Returns this
etaAt()
methodetaAt(at: Date | number): thisArrival time → a live countdown on the device (Date, unix seconds or ms).
Parameters
Prop
Type
Returns this
eta()
methodeta(text: string): thisA fixed ETA text instead of a countdown, e.g. "8 min" (the eta value).
Parameters
Prop
Type
Returns this
value()
methodvalue(key: string, value: string | number | boolean): thisOne {{placeholder}} value.
Parameters
Prop
Type
Returns this
values()
methodvalues(values: Record<string, string | number | boolean>): thisParameters
Prop
Type
Returns this
canceled()
methodcanceled(): thisShow the canceled state.
Returns this
done()
methoddone(): thisShow the finished state.
Returns this
data()
methoddata(data: LiveActivityData): thisPartial template data (merged).
Parameters
Prop
Type
Returns this
lang()
methodlang(lang: string): thisStart only: force one language for every recipient (default: each device's own).
Parameters
Prop
Type
Returns this
alert()
methodalert(title: string, body?: string): thisStart only: the iOS alert shown with the start.
Parameters
Prop
Type
Returns this
title()
methodtitle(v: string): thisParameters
Prop
Type
Returns this
subtitle()
methodsubtitle(v: string): thisParameters
Prop
Type
Returns this
body()
methodbody(v: string): thisParameters
Prop
Type
Returns this
status()
methodstatus(v: string): thisParameters
Prop
Type
Returns this
progress()
methodprogress(v: number): thisProgress 0–1 (or 0–100). Templated: toward the next step / along the bar.
Parameters
Prop
Type
Returns this
set()
methodset(key: string, value: unknown): thisParameters
Prop
Type
Returns this
state()
methodstate(state: Record<string, unknown>): thisParameters
Prop
Type
Returns this
toUsers()
methodtoUsers(distinctIds: string[]): thisParameters
Prop
Type
Returns this
toUser()
methodtoUser(distinctId: string): thisParameters
Prop
Type
Returns this
shared()
methodshared(): thisA shared activity (many users watching one event).
Returns this
attributes()
methodattributes(attributes: Record<string, unknown>): thisParameters
Prop
Type
Returns this
priority()
methodpriority(priority: number): thisAPNs priority: 5 = routine (unmetered), 10 = immediate (metered).
Parameters
Prop
Type
Returns this
staleAt()
methodstaleAt(iso: string): thisParameters
Prop
Type
Returns this
dismissAt()
methoddismissAt(iso: string): thisParameters
Prop
Type
Returns this
start()
methodasync start(): Promise<LiveActivityResult>Returns Promise<LiveActivityResult>
update()
methodasync update(): Promise<LiveActivityResult>Returns Promise<LiveActivityResult>
end()
methodasync end(): Promise<LiveActivityResult>Returns Promise<LiveActivityResult>
LiveActivityResult
interfaceios
propertyios: numberandroid
propertyandroid: numberiosTargets
propertyiosTargets?: numberStart only: iOS devices registered for the activity type.
iosWarning
propertyiosWarning?: stringStart only: why iOS got fewer deliveries than targets (no devices, APNs not set up, Apple's error).
LiveActivityData
interfaceData 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
propertystep?: string | nullCurrent step id (or label) of a steps template, e.g. "on_the_way".
state
propertystate?: 'active' | 'canceled' | 'done' | (string & {}) | null"active" | "canceled" | "done".
progress
propertyprogress?: number | null0–1: the tracker's position toward the next step (or along the bar).
etaAt
propertyetaAt?: number | nullArrival time, unix seconds — a live countdown on the device.
values
propertyvalues?: Record<string, string | number | boolean | null>Values for the template's {{placeholders}}; eta shows as fixed ETA text.
title
propertytitle?: string | nullOverride the template's texts for this activity.
subtitle
propertysubtitle?: string | nullbody
propertybody?: string | nullLiveActivityTemplateStartOptions
interfacedistinctIds
propertydistinctIds?: string[]Omit for a shared activity (everyone).
lang
propertylang?: stringForce one language for every recipient (default: each device's app language).
alert
propertyalert?: { title: string; body?: string }iOS alert shown with the start (default: the template's current texts).
attributes
propertyattributes?: Record<string, unknown>staleDate
propertystaleDate?: stringpriority
propertypriority?: number