PHPackages                             lepresk/laravel-onesignal - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. lepresk/laravel-onesignal

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

lepresk/laravel-onesignal
=========================

OneSignal push notification channel for Laravel. Send mobile and web push notifications through OneSignal API with support for iOS, Android, and web browsers.

v1.1.0(5mo ago)0448↓33.3%MITPHPPHP ^8.3CI passing

Since Nov 19Pushed 5mo agoCompare

[ Source](https://github.com/lepresk/laravel-onesignal)[ Packagist](https://packagist.org/packages/lepresk/laravel-onesignal)[ Docs](https://github.com/lepresk/laravel-onesignal)[ RSS](/packages/lepresk-laravel-onesignal/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (12)Versions (3)Used By (0)

Laravel OneSignal
=================

[](#laravel-onesignal)

[![Latest Version on Packagist](https://camo.githubusercontent.com/5c1a0005878fd041e73cf38ff438285a0e7d372bd38ffc18970730311fa2265e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c65707265736b2f6c61726176656c2d6f6e657369676e616c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lepresk/laravel-onesignal)[![Total Downloads](https://camo.githubusercontent.com/f8723ad1f95618b2e5a466dc13dfdedd9c49ec56731012507c674e413e67b1df/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c65707265736b2f6c61726176656c2d6f6e657369676e616c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lepresk/laravel-onesignal)[![License](https://camo.githubusercontent.com/73fd088a03c5bd3226e3508f6c7ec77cb277aa323e017b01646db23af87b4a0b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6c65707265736b2f6c61726176656c2d6f6e657369676e616c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lepresk/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
--------

[](#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
------------

[](#requirements)

- PHP 8.3 or higher
- Laravel 11.0 or 12.0
- OneSignal account and API credentials

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require lepresk/laravel-onesignal
```

The service provider will be automatically registered through Laravel's package auto-discovery.

### Publish Configuration

[](#publish-configuration)

Publish the configuration file to customize package behavior:

```
php artisan vendor:publish --tag=onesignal-config
```

### Environment Configuration

[](#environment-configuration)

Add your OneSignal credentials to your `.env` file:

```
ONESIGNAL_APP_ID=your-app-id
ONESIGNAL_REST_API_KEY=your-rest-api-key
ONESIGNAL_ANDROID_CHANNEL_ID=your-android-channel-id
```

Usage
-----

[](#usage)

### Basic Usage with Facade

[](#basic-usage-with-facade)

```
use Lepresk\LaravelOnesignal\Facades\OneSignal;
use Lepresk\LaravelOnesignal\PushMessage;

$message = (new PushMessage())
    ->withTitle('Hello World')
    ->withBody('This is a test notification')
    ->toExternalUserIds([1, 2, 3]);

$response = OneSignal::send($message);

if ($response->isSuccessful()) {
    echo "Notification sent! ID: " . $response->getNotificationId();
}
```

### Using Laravel Notifications

[](#using-laravel-notifications)

Create a notification class:

```
