Push
Push in the PHP SDK.
// access
$nexus->push()| Symbol | Kind | Summary |
|---|---|---|
Push | class | Push notifications. |
PushBuilder | class | Fluent builder for a transactional push. |
Push
classclass Inverge\Nexus\Resource\PushPush notifications. Server-side you mainly send transactional notifications to users or segments; campaigns, provider credentials, segments and templates are managed in the Nexus console. Delivered via FCM / APNs / Web Push.
Prefer the fluent builder for anything beyond a plain send:
$nexus->push()->notification()->title('…')->setSegments(['vip'])->send();
__construct
constructorfunction __construct(Inverge\Nexus\NexusClient $client)Parameters
Prop
Type
notification()
methodfunction notification(): Inverge\Nexus\Push\PushBuilderStart a fluent push notification. */
Returns Inverge\Nexus\Push\PushBuilder
send()
methodfunction send(array $distinctIds, array $message): arraySend a transactional push to one or more users (by distinctId), delivered across each user's registered devices.
$message:
- title (string, required)
- body, imageUrl (string)
- data (array<string,mixed>) — custom key/values delivered to the app
- options (array) — rich per-platform options: buttons, androidLargeIcon, androidBigPicture, androidVisibility, iosBadge, iosRelevanceScore, iosInterruptionLevel, webIcon, … (see the console composer).
Parameters
Prop
Type
Returns array<mixed> — { sent, failed }
sendRaw()
methodfunction sendRaw(array $payload): arraySend a fully-assembled payload (title + targeting: distinctIds / segmentIds / filter / all). Used by the builder; call it directly if you prefer.
Parameters
Prop
Type
Returns array<mixed> — { sent, failed, recipients }
sendToUser()
methodfunction sendToUser(string $distinctId, array $message): arraySend the same notification to a single user.
Parameters
Prop
Type
Returns array<mixed>
registerToken()
methodfunction registerToken(string $token, string $platform, array $options = []): arrayRegister (or refresh) a device token. Normally the client SDK does this; exposed for server-driven / BYO-token flows.
Parameters
Prop
Type
Returns array<mixed>
unregister()
methodfunction unregister(string $token): arrayStop delivering to a device token (e.g. on logout / uninstall).
Parameters
Prop
Type
Returns array<mixed>
PushBuilder
classclass Inverge\Nexus\Push\PushBuilderFluent builder for a transactional push. Compose content, rich per-platform
options and the audience, then send().
$nexus->push()->notification()
->title('Your order shipped')
->body('Track it in the app')
->data(['screen' => '/orders/42'])
->button('track', 'Track', ['url' => 'https://x/track'])
->iosBadge(1)
->androidVisibility('public')
->setSegments(['vip', 'active_7d']) // or ->toUsers([...]) / ->toAll()
->send(); // → ['sent' => .., 'failed' => .., 'recipients' => ..]__construct
constructorfunction __construct(Inverge\Nexus\NexusClient $client)Parameters
Prop
Type
title()
methodfunction title(string $title): selfParameters
Prop
Type
Returns self
body()
methodfunction body(string $body): selfParameters
Prop
Type
Returns self
image()
methodfunction image(string $url): selfParameters
Prop
Type
Returns self
data()
methodfunction data(array $data): selfCustom key/values delivered to the app (merged with any prior data).
Parameters
Prop
Type
Returns self
button()
methodfunction button(string $id, string $text, array $opts = []): selfAdd an action button. $opts: url, event, icon, style (primary|secondary|text).
Parameters
Prop
Type
Returns self
iosBadge()
methodfunction iosBadge(int $count): selfParameters
Prop
Type
Returns self
iosRelevanceScore()
methodfunction iosRelevanceScore(float $score): selfParameters
Prop
Type
Returns self
iosInterruptionLevel()
methodfunction iosInterruptionLevel(string $level): selfParameters
Prop
Type
Returns self
iosSubtitle()
methodfunction iosSubtitle(string $subtitle): selfParameters
Prop
Type
Returns self
androidVisibility()
methodfunction androidVisibility(string $visibility): selfAndroid lockscreen visibility: public | private | secret. */
Parameters
Prop
Type
Returns self
androidLargeIcon()
methodfunction androidLargeIcon(string $url): selfParameters
Prop
Type
Returns self
androidBigPicture()
methodfunction androidBigPicture(string $url): selfParameters
Prop
Type
Returns self
androidAccentColor()
methodfunction androidAccentColor(string $color): selfParameters
Prop
Type
Returns self
option()
methodfunction option(string $key, mixed $value): selfSet any option field directly (escape hatch). */
Parameters
Prop
Type
Returns self
options()
methodfunction options(array $options): selfMerge multiple options at once.
Parameters
Prop
Type
Returns self
toUsers()
methodfunction toUsers(array $distinctIds): selfTarget specific users by distinctId.
Parameters
Prop
Type
Returns self
toUser()
methodfunction toUser(string $distinctId): selfParameters
Prop
Type
Returns self
setSegments()
methodfunction setSegments(array $segmentIds): selfTarget saved segments (union). setSegments / toSegments are aliases.
Parameters
Prop
Type
Returns self
toSegments()
methodfunction toSegments(array $segmentIds): selfParameters
Prop
Type
Returns self
toSegment()
methodfunction toSegment(string $segmentId): selfParameters
Prop
Type
Returns self
where()
methodfunction where(array $filter): selfTarget an ad-hoc device filter (platform, lang, osType, appVersion, lastSeenDays, tags).
Parameters
Prop
Type
Returns self
toAll()
methodfunction toAll(): selfTarget every subscribed device (overrides other targets). Use with care. */
Returns self
send()
methodfunction send(): arrayDeliver the notification.
Returns array<mixed> — { sent, failed, recipients }
toArray()
methodfunction toArray(): arrayThe assembled request payload (without sending) — handy for testing.
Returns array<string, — mixed>
