Download the PHP package lepresk/laravel-onesignal without Composer
On this page you can find all versions of the php package lepresk/laravel-onesignal. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download lepresk/laravel-onesignal
More information about lepresk/laravel-onesignal
Files in lepresk/laravel-onesignal
Package laravel-onesignal
Short Description OneSignal push notification channel for Laravel. Send mobile and web push notifications through OneSignal API with support for iOS, Android, and web browsers.
License MIT
Homepage https://github.com/lepresk/laravel-onesignal
Informations about the package laravel-onesignal
Laravel OneSignal
OneSignal notification channel for Laravel applications. Send push notifications to iOS, Android, and web browsers through OneSignal's API with a clean, fluent interface.
Features
- Laravel Notification Channel integration
- Fluent message builder API
- Event system for notification lifecycle
- Comprehensive configuration options
- Custom exception handling
- PSR-3 logging support
- Type-safe implementation with PHP 8.3
- Full test coverage
Requirements
- PHP 8.3 or higher
- Laravel 12.x or 13.x
- OneSignal account and API credentials
Installation
Install the package via Composer:
The service provider will be automatically registered through Laravel's package auto-discovery.
Publish Configuration
Publish the configuration file to customize package behavior:
Environment Configuration
Add your OneSignal credentials to your .env file:
Usage
Basic Usage with Facade
Using Laravel Notifications
Create a notification class:
Send the notification:
Building Messages
Multi-language Support
Priority Settings
Targeting Users
External User IDs
External User IDs are custom identifiers you assign to your users in OneSignal (via OneSignal.login() in the SDK). They are sent with OneSignal's include_aliases (external_id) on the push channel. They cannot be combined with segments or filters in the same message.
Segments
Segments are groups of users defined in your OneSignal dashboard based on various criteria.
Tags
Tags are key-value pairs you set on user devices to create custom targeting rules.
Custom Data
Images and Buttons
The third parameter in addButton() is optional and specifies the URL to open when the button is clicked.
Advanced Options
Event Listeners
Listen to notification lifecycle events:
Example listener implementation:
Configuration
The package provides extensive configuration options in config/onesignal.php:
Default Values
The package applies default values from the configuration file. These defaults are used only when values are not explicitly set on the message.
Requests time out after http.timeout seconds. Failed requests are retried only when OneSignal did not process them (HTTP 423, 425, 429, 502, 503), so a notification is never sent twice.
Logs never include message contents or recipient identifiers: only the audience size, segment names, notification ID and recipient count.
Testing
Run the test suite:
Run tests with coverage:
Code Quality
Format code with Laravel Pint:
Run static analysis with PHPStan:
Upgrading to 2.0
- Laravel 11 is no longer supported.
- External user IDs are sent as
include_aliases.external_id(strings) withtarget_channel: push, replacing OneSignal's deprecatedinclude_external_user_ids. UpdateNotificationSendinglisteners that read the payload. - Combining
toUser()/toExternalUserIds()with segments or tags now throwsInvalidMessageException.
Deprecations
| Deprecated | Replacement | Removal |
|---|---|---|
PushMessage::withHightPriority() |
PushMessage::withHighPriority() |
3.0 |
Deprecated methods trigger an E_USER_DEPRECATED notice, which Laravel writes to the log channel set by LOG_DEPRECATIONS_CHANNEL.
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.
Credits
- lepresk
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-onesignal with dependencies
ext-json Version *
illuminate/contracts Version ^12.0|^13.0
illuminate/support Version ^12.0|^13.0
illuminate/notifications Version ^12.0|^13.0
norkunas/onesignal-php-api Version ^2.16
nyholm/psr7 Version ^1.8
psr/log Version ^3.0
symfony/deprecation-contracts Version ^3.0
symfony/http-client Version ^7.1|^8.0