PHPackages                             fleetrunnr/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. fleetrunnr/laravel-onesignal

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

fleetrunnr/laravel-onesignal
============================

OneSignal Notifications driver

v2.4.0(4y ago)02.5kMITPHPPHP ^7.2.0|^8.0

Since Aug 23Pushed 4y agoCompare

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

READMEChangelog (1)Dependencies (6)Versions (19)Used By (0)

OneSignal notifications channel for Laravel 5.3+
================================================

[](#onesignal-notifications-channel-for-laravel-53)

[![Latest Version on Packagist](https://camo.githubusercontent.com/175bffa259a74dd28b91370d9256456d7df8aa0ec3822961bceda6048c6455f4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c61726176656c2d6e6f74696669636174696f6e2d6368616e6e656c732f6f6e657369676e616c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/laravel-notification-channels/onesignal)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/22c37a27e3a5eb4599472ecfb8c8c8fca497e77f7e4f19b318801676b1e4c01e/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6c61726176656c2d6e6f74696669636174696f6e2d6368616e6e656c732f6f6e657369676e616c2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/laravel-notification-channels/onesignal)[![StyleCI](https://camo.githubusercontent.com/5aa508ba52e7eef928bd37347e405de61819fed2055ea4391529980b2f2f0211/68747470733a2f2f7374796c6563692e696f2f7265706f732f36353337393332312f736869656c64)](https://styleci.io/repos/65379321)[![SensioLabsInsight](https://camo.githubusercontent.com/cc88870747ad11c0f3b0a6d4efcde14e8d74df772b765e80d8a624cd11836395/68747470733a2f2f696d672e736869656c64732e696f2f73656e73696f6c6162732f692f39303135363931662d313330642d346663612d383731302d3732613031306162633638342e7376673f7374796c653d666c61742d737175617265)](https://insight.sensiolabs.com/projects/9015691f-130d-4fca-8710-72a010abc684)[![Quality Score](https://camo.githubusercontent.com/45431d1c3b806dba3e8605a1538e81536200cd512d984f06090c5030b501cd20/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6c61726176656c2d6e6f74696669636174696f6e2d6368616e6e656c732f6f6e657369676e616c2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/laravel-notification-channels/onesignal)[![Code Coverage](https://camo.githubusercontent.com/267277fb3c5469eff6dc9fa894adab12b1d2fc383af9dce1999f73ad95ba0a93/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6c61726176656c2d6e6f74696669636174696f6e2d6368616e6e656c732f6f6e657369676e616c2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/laravel-notification-channels/onesignal/?branch=master)[![Total Downloads](https://camo.githubusercontent.com/486d9942ee06a1d46b3bc42a262c9563a97fc106d7316e63a56173fe46ce48a1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c61726176656c2d6e6f74696669636174696f6e2d6368616e6e656c732f6f6e657369676e616c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/laravel-notification-channels/onesignal)

This package makes it easy to send [OneSignal notifications](https://documentation.onesignal.com/docs) with Laravel 5.3+.

Contents
--------

[](#contents)

- [Installation](#installation)
    - [Setting up your OneSignal account](#setting-up-your-onesignal-account)
- [Usage](#usage)
    - [Available Message methods](#all-available-methods)
    - [Button usage](#button-usage)
    - [WebButton usage](#webbutton-usage)
- [Changelog](#changelog)
- [Testing](#testing)
- [Security](#security)
- [Contributing](#contributing)
- [Credits](#credits)
- [License](#license)

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

[](#installation)

You can install the package via composer:

```
$ composer require laravel-notification-channels/onesignal
```

If you're installing the package in Laravel 5.4 or lower, you must import the service provider:

```
// config/app.php
'providers' => [
    ...
    NotificationChannels\OneSignal\OneSignalServiceProvider::class,
],
```

### Setting up your OneSignal account

[](#setting-up-your-onesignal-account)

Add your OneSignal App ID and REST API Key to your `config/services.php`:

```
// config/services.php
...
'onesignal' => [
    'app_id' => env('ONESIGNAL_APP_ID'),
    'rest_api_key' => env('ONESIGNAL_REST_API_KEY')
],
...
```

Usage
-----

[](#usage)

Now you can use the channel in your `via()` method inside the notification:

```
use NotificationChannels\OneSignal\OneSignalChannel;
use NotificationChannels\OneSignal\OneSignalMessage;
use NotificationChannels\OneSignal\OneSignalWebButton;
use Illuminate\Notifications\Notification;

class AccountApproved extends Notification
{
    public function via($notifiable)
    {
        return [OneSignalChannel::class];
    }

    public function toOneSignal($notifiable)
    {
        return OneSignalMessage::create()
            ->setSubject("Your {$notifiable->service} account was approved!")
            ->setBody("Click here to see details.")
            ->setUrl('http://onesignal.com')
            ->webButton(
                OneSignalWebButton::create('link-1')
                    ->text('Click here')
                    ->icon('https://upload.wikimedia.org/wikipedia/commons/4/4f/Laravel_logo.png')
                    ->url('http://laravel.com')
            );
    }
}
```

In order to let your Notification know which OneSignal user(s) you are targeting, add the `routeNotificationForOneSignal` method to your Notifiable model.

You can either return a single player-id, or if you want to notify multiple player IDs just return an array containing all IDs.

```
public function routeNotificationForOneSignal()
{
    return 'ONE_SIGNAL_PLAYER_ID';
}
```

If you want to send the notification based on the OneSignal "syncHashedEmail" feature just return an array with the index "email". **It isn't possible to use multiple E-Mails on one filter because of a limitation of the OneSignal API.**

```
public function routeNotificationForOneSignal()
{
    return ['email' => 'example@example.com'];
}
```

If you want to send the notification based on the OneSignal "Tags" feature just return an array with the index "tags".

```
public function routeNotificationForOneSignal()
{
    return ['tags' => ['key' => 'device_uuid', 'relation' => '=', 'value' => '1234567890-abcdefgh-1234567']];
}
```

If you want to send the notification based on an external user id you set using the `setExternalUserId` feature. This makes it really easy to target users based on their Laravel User Ids.

```
public function routeNotificationForOneSignal()
{
    return ['include_external_user_ids' => $this->id];
}
```

### All available methods

[](#all-available-methods)

- `setSubject('')`: Accepts a string value for the title.
- `setBody('')`: Accepts a string value for the notification body.
- `setIcon('')`: Accepts an url for the icon.
- `setUrl('')`: Accepts an url for the notification click event.
- `webButton(OneSignalWebButton $button)`: Allows you to add action buttons to the notification (Chrome 48+ (web push) only).
- `button(OneSignalButton $button)`: Allows you to add buttons to the notification (Supported by iOS 8.0 and Android 4.1+ devices. Icon only works for Android).
- `setData($key, $value)`: Allows you to set additional data for the message payload. For more information check the [OneSignal documentation](https://documentation.onesignal.com/reference).
- `setParameter($key, $value)`: Allows you to set additional parameters for the message payload that are available for the REST API. For more information check the [OneSignal documentation](https://documentation.onesignal.com/reference).
- `setImageAttachments($imageUrl)`: Allows you to set one Image to all possible Attachments [OneSignal Attachment documentation](https://documentation.onesignal.com/reference#section-attachments).

### Button usage

[](#button-usage)

```
OneSignalMessage::create()
    ->button(
        OneSignalButton::create('id')
            ->text('button text')
            ->icon('button icon')
    );
```

### WebButton usage

[](#webbutton-usage)

```
OneSignalMessage::create()
    ->webButton(
        OneSignalWebButton::create('id')
            ->text('button text')
            ->icon('button icon')
            ->url('button url')
    );
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Marcel Pociot](https://github.com/mpociot)
- [Freek Van der Herten](https://github.com/freekmurze)
- [Lukas Kämmerling](https://github.com/LKDevelopment)
- [David Llop](https://github.com/Lloople)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor3

3 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~159 days

Recently: every ~239 days

Total

14

Last Release

1471d ago

Major Versions

1.2.0 → v2.0.0-rc12019-01-03

PHP version history (4 changes)1.0.0PHP &gt;=5.6.4

1.1.0PHP &gt;=7.0.0

v2.0.0PHP ^7.2.0

v2.3.0PHP ^7.2.0|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/f46f119bf759e8225a511a823651f26ff9095eeffdd4cd0ded06dffc81afb072?d=identicon)[fleetrunnr](/maintainers/fleetrunnr)

---

Top Contributors

[![mpociot](https://avatars.githubusercontent.com/u/804684?v=4)](https://github.com/mpociot "mpociot (25 commits)")[![LKaemmerling](https://avatars.githubusercontent.com/u/4281581?v=4)](https://github.com/LKaemmerling "LKaemmerling (25 commits)")[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (14 commits)")[![Lloople](https://avatars.githubusercontent.com/u/5665466?v=4)](https://github.com/Lloople "Lloople (11 commits)")[![timacdonald](https://avatars.githubusercontent.com/u/24803032?v=4)](https://github.com/timacdonald "timacdonald (5 commits)")[![themsaid](https://avatars.githubusercontent.com/u/4332182?v=4)](https://github.com/themsaid "themsaid (4 commits)")[![mansourwakim](https://avatars.githubusercontent.com/u/104381981?v=4)](https://github.com/mansourwakim "mansourwakim (3 commits)")[![pavoltanuska](https://avatars.githubusercontent.com/u/4980667?v=4)](https://github.com/pavoltanuska "pavoltanuska (3 commits)")[![AshPowell](https://avatars.githubusercontent.com/u/7704739?v=4)](https://github.com/AshPowell "AshPowell (2 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (1 commits)")[![casperboone](https://avatars.githubusercontent.com/u/15815208?v=4)](https://github.com/casperboone "casperboone (1 commits)")[![mattpawley](https://avatars.githubusercontent.com/u/4113253?v=4)](https://github.com/mattpawley "mattpawley (1 commits)")[![abr4xas](https://avatars.githubusercontent.com/u/405484?v=4)](https://github.com/abr4xas "abr4xas (1 commits)")[![Norgul](https://avatars.githubusercontent.com/u/11718157?v=4)](https://github.com/Norgul "Norgul (1 commits)")[![oyed](https://avatars.githubusercontent.com/u/172114265?v=4)](https://github.com/oyed "oyed (1 commits)")[![pedro-santiago](https://avatars.githubusercontent.com/u/6331494?v=4)](https://github.com/pedro-santiago "pedro-santiago (1 commits)")[![studnitz](https://avatars.githubusercontent.com/u/9549394?v=4)](https://github.com/studnitz "studnitz (1 commits)")[![thecaliskan](https://avatars.githubusercontent.com/u/13554944?v=4)](https://github.com/thecaliskan "thecaliskan (1 commits)")[![daraul](https://avatars.githubusercontent.com/u/2440975?v=4)](https://github.com/daraul "daraul (1 commits)")[![abhimanyu003](https://avatars.githubusercontent.com/u/265913?v=4)](https://github.com/abhimanyu003 "abhimanyu003 (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/fleetrunnr-laravel-onesignal/health.svg)

```
[![Health](https://phpackages.com/badges/fleetrunnr-laravel-onesignal/health.svg)](https://phpackages.com/packages/fleetrunnr-laravel-onesignal)
```

###  Alternatives

[laravel-notification-channels/telegram

Telegram Notifications Channel for Laravel

1.1k3.4M35](/packages/laravel-notification-channels-telegram)[laravel-notification-channels/webpush

Web Push Notifications driver for Laravel.

7984.5M16](/packages/laravel-notification-channels-webpush)[laravel-notification-channels/fcm

FCM (Firebase Cloud Messaging) Notifications Driver for Laravel

5917.0M16](/packages/laravel-notification-channels-fcm)[s-ichikawa/laravel-sendgrid-driver

This library adds a 'sendgrid' mail driver to Laravel.

4139.3M1](/packages/s-ichikawa-laravel-sendgrid-driver)[laravel-notification-channels/twilio

Provides Twilio notification channel for Laravel

2587.7M12](/packages/laravel-notification-channels-twilio)[laravel-notification-channels/apn

Apple APN Push Notification Channel

2021.9M4](/packages/laravel-notification-channels-apn)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
