Download the PHP package justpush/laravel-notification-channel without Composer
On this page you can find all versions of the php package justpush/laravel-notification-channel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download justpush/laravel-notification-channel
More information about justpush/laravel-notification-channel
Files in justpush/laravel-notification-channel
Package laravel-notification-channel
Short Description JustPush notification channel for Laravel: send push notifications to iOS and Android with $user->notify().
License MIT
Homepage https://justpush.io
Informations about the package laravel-notification-channel
JustPush notification channel for Laravel
Send push notifications to iOS and Android through JustPush with Laravel's
notification system: $user->notify(new OrderShipped($order)).
It uses the official JustPush PHP SDK to talk to the JustPush API.
- Laravel 12 and 13, PHP 8.2 or newer
- Priorities, sounds, buttons, button groups, images, expiry and acknowledgements
- Per-user tokens, an app-wide token, or on-demand routes
Installation
The service provider registers itself. Add your API token to config/services.php:
You'll find your API token in the JustPush app.
Usage
toJustPush() can also return a plain string, which becomes the message text.
Who receives it
JustPush tokens belong to a JustPush account, and the push goes to that account's devices.
-
Per user: add a route method to your notifiable model. Return
nullto fall back to the app token. - App-wide: without a route, the channel uses
services.justpush.token. That's handy for notifications to yourself or your team, e.g.$admin->notify(new NewSignup($user)). - On demand:
If there's no token at all, the notification is skipped for this channel.
Message options
| Method | |
|---|---|
create($message), message(), title() |
At least a message or a title is required. |
topic($name) |
The topic name. An existing topic with that name is used, or a new one is created. |
topicToken($token) |
Target a topic by its API token instead. |
priority() |
-2…2 or lowest, low, normal, high, highest. Shortcuts: lowestPriority() … highestPriority(). |
sound($name) |
See JustPushMessage::SOUNDS. none is silent. |
button($cta, $url, $actionRequired) |
Up to 10. Labels over 25 characters are cut. |
buttonGroup($name, $cta, $buttons) |
Up to 4 groups of up to 10 buttons. |
image(), imageData(), imageFile() |
Up to 10. The first image becomes the notification banner. |
expiresIn($seconds) |
Hide the message after this many seconds. |
acknowledge(...) |
Ask for an acknowledgement. Optionally re-send every retryEvery seconds (10–65535) up to maxRetries times (0–255), and have JustPush POST callbackParams plus the acknowledging device to callbackUrl, which must be publicly reachable. |
Invalid values throw an InvalidArgumentException when you set them.
The response and errors
The channel returns the API's response, which Laravel passes to the NotificationSent event as $event->response:
When JustPush can't be reached or rejects the message, the channel throws
NotificationChannels\JustPush\Exceptions\CouldNotSendNotification. getStatus() returns the HTTP
status, or null for connection errors, and getErrors() returns per-field messages for a 422.
Queue the notification (implements ShouldQueue) to get Laravel's retries.
Testing
License
MIT. See LICENSE.
All versions of laravel-notification-channel with dependencies
guzzlehttp/guzzle Version ^7.2
illuminate/notifications Version ^12.0|^13.0
illuminate/support Version ^12.0|^13.0
justpush/justpush-php-sdk Version ^1.1