InvergeDocs
JavaScriptAPI reference

Push

Push in the JavaScript SDK.

// access
nexus.push
SymbolKindSummary
NexusPushclassPush notifications.
NexusPushBuilderclassFluent builder for a transactional push.
PushMessageinterface
PushOptionsinterfaceRich per-platform options — same fields as the console composer.
PushActionButtoninterface
PushSendResultinterface

NexusPush

class

Push 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

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

Parameters

Prop

Type

Returns NexusPush

View source

notification()

method
notification(): NexusPushBuilder

Start a fluent push notification.

Returns NexusPushBuilder

View source

send()

method
send(distinctIds: string[], message: PushMessage): Promise<PushSendResult>

Send a plain notification to specific users (by distinctId).

Parameters

Prop

Type

Returns Promise<PushSendResult>

View source

sendToUser()

method
sendToUser(distinctId: string, message: PushMessage): Promise<PushSendResult>

Parameters

Prop

Type

Returns Promise<PushSendResult>

View source

sendRaw()

method
async sendRaw(payload: Record<string, unknown>): Promise<PushSendResult>

Send a fully-assembled payload (title + targeting). Used by the builder.

Parameters

Prop

Type

Returns Promise<PushSendResult>

View source

registerToken()

method
async 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

View source

unregister()

method
async unregister(token: string): Promise<void>

Parameters

Prop

Type

View source

NexusPushBuilder

class

Fluent builder for a transactional push.

NexusPushBuilder

constructor
new NexusPushBuilder(http: NexusHttp)

Parameters

Prop

Type

Returns NexusPushBuilder

View source

title()

method
title(v: string): this

Parameters

Prop

Type

Returns this

View source

body()

method
body(v: string): this

Parameters

Prop

Type

Returns this

View source

image()

method
image(url: string): this

Parameters

Prop

Type

Returns this

View source

data()

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

Parameters

Prop

Type

Returns this

View source

button()

method
button(id: string, text: string, opts: Omit<PushActionButton, 'id' | 'text'> = {}): this

Parameters

Prop

Type

Returns this

View source

iosBadge()

method
iosBadge(count: number): this

Parameters

Prop

Type

Returns this

View source

iosInterruptionLevel()

method
iosInterruptionLevel(level: PushOptions['iosInterruptionLevel']): this

Parameters

Prop

Type

Returns this

View source

androidVisibility()

method
androidVisibility(v: PushOptions['androidVisibility']): this

Parameters

Prop

Type

Returns this

View source

androidLargeIcon()

method
androidLargeIcon(url: string): this

Parameters

Prop

Type

Returns this

View source

androidBigPicture()

method
androidBigPicture(url: string): this

Parameters

Prop

Type

Returns this

View source

option()

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

Set any option field directly.

Parameters

Prop

Type

Returns this

View source

options()

method
options(options: PushOptions): 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

setSegments()

method
setSegments(segmentIds: string[]): this

Target saved segments (union). toSegments is an alias.

Parameters

Prop

Type

Returns this

View source

toSegments()

method
toSegments(segmentIds: string[]): this

Parameters

Prop

Type

Returns this

View source

toSegment()

method
toSegment(segmentId: string): this

Parameters

Prop

Type

Returns this

View source

where()

method
where(filter: Record<string, unknown>): this

Ad-hoc device filter (platform, lang, osType, appVersion, lastSeenDays, tags).

Parameters

Prop

Type

Returns this

View source

toAll()

method
toAll(): this

Everyone (overrides other targets).

Returns this

View source

send()

method
async send(): Promise<PushSendResult>

Deliver the notification.

Returns Promise<PushSendResult>

View source

PushMessage

interface

title

property
title: string

body

property
body?: string

imageUrl

property
imageUrl?: string

data

property
data?: Record<string, unknown>

options

property
options?: PushOptions

PushOptions

interface

Rich per-platform options — same fields as the console composer.

buttons

property
buttons?: PushActionButton[]

androidLargeIcon

property
androidLargeIcon?: string

androidBigPicture

property
androidBigPicture?: string

androidSmallIcon

property
androidSmallIcon?: string

androidVisibility

property
androidVisibility?: 'public' | 'private' | 'secret'

androidAccentColor

property
androidAccentColor?: string

iosBadge

property
iosBadge?: number

iosRelevanceScore

property
iosRelevanceScore?: number

iosInterruptionLevel

property
iosInterruptionLevel?: 'passive' | 'active' | 'time-sensitive' | 'critical'

iosSubtitle

property
iosSubtitle?: string

webIcon

property
webIcon?: string

webImage

property
webImage?: string

webBadge

property
webBadge?: string

PushActionButton

interface

id

property
id: string

text

property
text: string

action

property
action?: 'dismiss' | 'url' | 'event'

url

property
url?: string

event

property
event?: string

icon

property
icon?: string

style

property
style?: string

PushSendResult

interface

sent

property
sent: number

failed

property
failed: number

recipients

property
recipients?: number

On this page