PHPackages                             timsinakiran/onesignal-laravel10 - 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. timsinakiran/onesignal-laravel10

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

timsinakiran/onesignal-laravel10
================================

OneSignal Notifications driver

03PHP

Since Mar 5Pushed 3y agoCompare

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

READMEChangelogDependenciesVersions (2)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'),
    'guzzle_client_timeout' => env('ONESIGNAL_GUZZLE_CLIENT_TIMEOUT', 0),
],
...
```

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

16

—

LowBetter than 5% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity25

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/351e3224dcfda5f2fc1a86fb6424f60a9a060a39c938c6338a244d01912e077d?d=identicon)[kiran1991](/maintainers/kiran1991)

---

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)")[![timsinakiran](https://avatars.githubusercontent.com/u/50225225?v=4)](https://github.com/timsinakiran "timsinakiran (7 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)")[![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)")[![atymic](https://avatars.githubusercontent.com/u/50683531?v=4)](https://github.com/atymic "atymic (2 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (1 commits)")[![ajayfroiden](https://avatars.githubusercontent.com/u/6275382?v=4)](https://github.com/ajayfroiden "ajayfroiden (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)")[![Sml995](https://avatars.githubusercontent.com/u/16786173?v=4)](https://github.com/Sml995 "Sml995 (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)")

### Embed Badge

![Health badge](/badges/timsinakiran-onesignal-laravel10/health.svg)

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

###  Alternatives

[tijsverkoyen/css-to-inline-styles

CssToInlineStyles is a class that enables you to convert HTML-pages/files into HTML-pages/files with inline styles. This is very useful when you're sending emails.

5.8k505.3M227](/packages/tijsverkoyen-css-to-inline-styles)[minishlink/web-push

Web Push library for PHP

1.9k12.0M53](/packages/minishlink-web-push)[laravel-notification-channels/twilio

Provides Twilio notification channel for Laravel

2587.7M12](/packages/laravel-notification-channels-twilio)[spatie/url-signer

Generate a url with an expiration date and signature to prevent unauthorized access

4422.3M16](/packages/spatie-url-signer)[mattketmo/email-checker

Throwaway email detection library

2742.0M5](/packages/mattketmo-email-checker)[laravel-notification-channels/discord

Laravel notification driver for Discord.

2371.3M11](/packages/laravel-notification-channels-discord)

PHPackages © 2026

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