Push
Push in the JavaScript SDK.
// access
nexus.push| Symbol | Kind | Summary |
|---|---|---|
NexusPush | class | Push notifications. |
NexusPushBuilder | class | Fluent builder for a transactional push. |
PushMessage | interface | |
PushOptions | interface | Rich per-platform options — same fields as the console composer. |
PushActionButton | interface | |
PushSendResult | interface |
NexusPush
classPush notifications. Send transactional push to users or segments; campaigns, provider credentials, segments and templates are managed in the console.
Prefer the fluent builder:
nexus.push.notification().title('…').setSegments(['vip']).send().
NexusPush
constructornew NexusPush(http: NexusHttp, id: NexusIdentity)Parameters
Prop
Type
Returns NexusPush
notification()
methodnotification(): NexusPushBuilderStart a fluent push notification.
Returns NexusPushBuilder
send()
methodsend(distinctIds: string[], message: PushMessage): Promise<PushSendResult>Send a plain notification to specific users (by distinctId).
Parameters
Prop
Type
Returns Promise<PushSendResult>
sendToUser()
methodsendToUser(distinctId: string, message: PushMessage): Promise<PushSendResult>Parameters
Prop
Type
Returns Promise<PushSendResult>
sendRaw()
methodasync sendRaw(payload: Record<string, unknown>): Promise<PushSendResult>Send a fully-assembled payload (title + targeting). Used by the builder.
Parameters
Prop
Type
Returns Promise<PushSendResult>
registerToken()
methodasync registerToken(token: string, platform: 'ios' | 'android' | 'web', options: { provider?: string; distinctId?: string; deviceKey?: string; appVersion?: string; osType?: string; osVersion?: string; lang?: string; tags?: Record<string, string>; } = {}): Promise<void>Register (or refresh) a device token. Normally the client SDK does this.
Parameters
Prop
Type
unregister()
methodasync unregister(token: string): Promise<void>Parameters
Prop
Type
NexusPushBuilder
classFluent builder for a transactional push.
NexusPushBuilder
constructornew NexusPushBuilder(http: NexusHttp)Parameters
Prop
Type
Returns NexusPushBuilder
title()
methodtitle(v: string): thisParameters
Prop
Type
Returns this
body()
methodbody(v: string): thisParameters
Prop
Type
Returns this
image()
methodimage(url: string): thisParameters
Prop
Type
Returns this
data()
methoddata(data: Record<string, unknown>): thisParameters
Prop
Type
Returns this
button()
methodbutton(id: string, text: string, opts: Omit<PushActionButton, 'id' | 'text'> = {}): thisParameters
Prop
Type
Returns this
iosBadge()
methodiosBadge(count: number): thisParameters
Prop
Type
Returns this
iosInterruptionLevel()
methodiosInterruptionLevel(level: PushOptions['iosInterruptionLevel']): thisParameters
Prop
Type
Returns this
androidVisibility()
methodandroidVisibility(v: PushOptions['androidVisibility']): thisParameters
Prop
Type
Returns this
androidLargeIcon()
methodandroidLargeIcon(url: string): thisParameters
Prop
Type
Returns this
androidBigPicture()
methodandroidBigPicture(url: string): thisParameters
Prop
Type
Returns this
option()
methodoption(key: string, value: unknown): thisSet any option field directly.
Parameters
Prop
Type
Returns this
options()
methodoptions(options: PushOptions): thisParameters
Prop
Type
Returns this
toUsers()
methodtoUsers(distinctIds: string[]): thisParameters
Prop
Type
Returns this
toUser()
methodtoUser(distinctId: string): thisParameters
Prop
Type
Returns this
setSegments()
methodsetSegments(segmentIds: string[]): thisTarget saved segments (union). toSegments is an alias.
Parameters
Prop
Type
Returns this
toSegments()
methodtoSegments(segmentIds: string[]): thisParameters
Prop
Type
Returns this
toSegment()
methodtoSegment(segmentId: string): thisParameters
Prop
Type
Returns this
where()
methodwhere(filter: Record<string, unknown>): thisAd-hoc device filter (platform, lang, osType, appVersion, lastSeenDays, tags).
Parameters
Prop
Type
Returns this
toAll()
methodtoAll(): thisEveryone (overrides other targets).
Returns this
send()
methodasync send(): Promise<PushSendResult>Deliver the notification.
Returns Promise<PushSendResult>
PushMessage
interfacetitle
propertytitle: stringbody
propertybody?: stringimageUrl
propertyimageUrl?: stringdata
propertydata?: Record<string, unknown>options
propertyoptions?: PushOptionsPushOptions
interfaceRich per-platform options — same fields as the console composer.
buttons
propertybuttons?: PushActionButton[]androidLargeIcon
propertyandroidLargeIcon?: stringandroidBigPicture
propertyandroidBigPicture?: stringandroidSmallIcon
propertyandroidSmallIcon?: stringandroidVisibility
propertyandroidVisibility?: 'public' | 'private' | 'secret'androidAccentColor
propertyandroidAccentColor?: stringiosBadge
propertyiosBadge?: numberiosRelevanceScore
propertyiosRelevanceScore?: numberiosInterruptionLevel
propertyiosInterruptionLevel?: 'passive' | 'active' | 'time-sensitive' | 'critical'iosSubtitle
propertyiosSubtitle?: stringwebIcon
propertywebIcon?: stringwebImage
propertywebImage?: stringwebBadge
propertywebBadge?: stringPushActionButton
interfaceid
propertyid: stringtext
propertytext: stringaction
propertyaction?: 'dismiss' | 'url' | 'event'url
propertyurl?: stringevent
propertyevent?: stringicon
propertyicon?: stringstyle
propertystyle?: stringPushSendResult
interfacesent
propertysent: numberfailed
propertyfailed: numberrecipients
propertyrecipients?: number