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

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

shokme/laravel-onesignal
========================

Laravel OneSignal Notification

v1.0.0(3y ago)03.3k1MITPHPPHP ^8.1

Since Aug 19Pushed 3y ago1 watchersCompare

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

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

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

[](#laravel-onesignal)

The `shokme/laravel-onesignal` package provides easy to use facade to send notification to your users via onesignal. It uses the latest functionality of `PHP8.1`.

Here's a demo of how you can use it:

```
$response = OneSignal::make()
    ->subject('Notification Title')
    ->contents(['en' => 'Notification Body', 'es' => 'Translated Notification Body'])
    ->url('en.myapp.service://')
    ->sendTo(SignalType::Users, [1, 2, 3]);
```

Find below the documentation of all available methods.

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

[](#installation)

You can install the package via composer:

```
composer require shokme/laravel-onesignal
```

define environment variables:

```
ONESIGNAL_APP_ID=your-app-id
ONESIGNAL_REST_API_KEY=your-api-key
```

You may want to publish the config file to update http timeout and retry:

```
php artisan vendor:publish --provider="Shokme\OneSignal\OneSignalServiceProvider" --tag="config"
```

Documentation
-------------

[](#documentation)

### Message

[](#message)

You can use a string or array of language to set the message(title,subtitle,contents). If you set a `string`, it will be set to 'en' for default language.

```
OneSignal::subject('Notification Title'); // ['en' => 'Notification Title']
OneSignal::subject(['en' => 'Notification Title', 'nl' => 'Translated Notification Title']);
```

### Url

[](#url)

You can set the url to open when user click the notification.

```
OneSignal::url('https://example.com');
```

### Buttons

[](#buttons)

#### Mobile

[](#mobile)

```
OneSignal::buttons(ButtonType::Mobile, [
    ['id' => 'action-1', 'text' => 'Action To Trigger'],
    ...
]);
```

#### Web

[](#web)

```
OneSignal::buttons(ButtonType::Web, [
    ['id' => 'action-1', 'text' => 'Action To Trigger', 'url' => 'https://app.com'],
    ...
]);
```

### Additional Parameters

[](#additional-parameters)

If you have to use some parameters that are not supported by the package, you can set them using this method:

```
OneSignal::parameters(['template_id' => 'be4a8044-bbd6-11e4-a581-000c2940e62c'])
```

### Schedule and Delay

[](#schedule-and-delay)

You can read the [OneSignal](https://documentation.onesignal.com/reference/create-notification#delivery) documentation for more information.

#### Schedule

[](#schedule)

is equal to `send_after` parameter.

```
OneSignal::schedule(Carbon::parse('17 april 2022')->timezone('GMT+3'));
```

#### Delay

[](#delay)

is equal to `delayed_option` parameter, if `timezone` is set you need to set the second arguments(`$time`).

```
$lastActive = OneSignal::delay(Delay::LastActive);
$timezone = OneSignal::delay(Delay::Timezone, '9:00AM');
```

### Channels

[](#channels)

When using only one channel.

```
OneSignal::channel(Channel::Sms);
```

When using multiple channel.

```
OneSignal::channels([Channel::Sms, Channel::Push]);
```

### Filters

[](#filters)

You can see [Available Filters](https://documentation.onesignal.com/reference/create-notification#send-to-users-based-on-filters).
If you want to know how to [Format Filters](https://documentation.onesignal.com/reference/create-notification#formatting-filters).

```
OneSignal::filters([
    ['field' => 'tag', 'key' => 'test', 'relation' => '=', 'value' => 'test'],
    ['field' => 'tag', 'key' => 'test2', 'relation' => '>=', 'value' => 'test2'],
])
```

or you can chain filter, watch out in some case you may need to combine with `filters()` because some fields aren't supported at the moment.

```
OneSignal::filter('tag', 'level', 10)
    ->filter('amount_spent', '>', 0)
    ->filter('session_count', 5);

//[
//    ['field' => 'tag', 'key' => 'test', 'relation' => '=', 'value' => 10],
//    ['field' => 'amount_spent', 'relation' => '>=', 'value' => '0'],
//    ['field' => 'session_count', 'relation' => '=', 'value' => '5'],
//]
```

### Sending Notification

[](#sending-notification)

You can send multiple kind of notification. By default, the notification use the `push` channel.

```
$response = OneSignal::sendTo(SignalType::All);
$response = OneSignal::sendTo(SignalType::Users, [1,2,3]);
$response = OneSignal::channel(Channel::Sms)->sendTo(SignalType::Players, ['player_id-1', 'player_id-2']);
$response = OneSignal::sendTo(SignalType::Segments, ['Active Users', 'Inactive Users']);
$response = OneSignal::filters([...])->sendTo(SignalType::Filters);
```

### Notifications

[](#notifications)

#### Retrieve all

[](#retrieve-all)

You can retrieve all notifications using:

```
$response = OneSignal::getNotifications();
// Dashboard, Api or Automated
$response = OneSignal::getNotifications(Kind::Dashboard);
```

#### Retrieve one

[](#retrieve-one)

You can add a second argument to specify your `$outcomes`. Check the OneSignal outcomes [documentation](https://documentation.onesignal.com/reference/view-notification).

```
$response = OneSignal::getNotification('notification_id');
```

#### Cancel

[](#cancel)

```
$response = OneSignal::cancel('notification_id');
```

### Player

[](#player)

OneSignal Device [documentation](https://documentation.onesignal.com/reference/add-a-device)

#### Add

[](#add)

All device type can be found in Shokme\\OneSignal\\Enum\\DeviceType.php.

```
$response = OneSignal::addPlayer(DeviceType::Android, 'push-token-from-google', 'Australia/Sydney', [
    'device_model' => 'Nexus 5X',
]);
```

#### Edit

[](#edit)

```
$response = OneSignal::editPlayer('push-token-from-google', timezone: 'Europe/Brussels');
```

Contribution
------------

[](#contribution)

This package might not be complete as it is made for personal use. If you want to contribute, please feel free to open an issue or pull request.

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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

Unknown

Total

1

Last Release

1368d ago

### Community

Maintainers

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

![](https://avatars.githubusercontent.com/u/114988140?v=4)[fredericTribu](/maintainers/fredericTribu)[@FredericTribu](https://github.com/FredericTribu)

---

Top Contributors

[![shokme](https://avatars.githubusercontent.com/u/9437903?v=4)](https://github.com/shokme "shokme (7 commits)")

---

Tags

laravelpushnotificationWebPushonesignal

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[berkayk/onesignal-laravel

OneSignal Push Wrapper Laravel

5295.9M12](/packages/berkayk-onesignal-laravel)[bentools/webpush-bundle

Send push notifications through Web Push Protocol to your Symfony users.

71274.3k](/packages/bentools-webpush-bundle)[dropfan/onesignal-server-api

OneSignal server API for PHP, you can push notifications to any platform. (iOS/APNS, Android/GCM/FCM, WP, Web/Chrome/Safari...etc.) No third-party dependency that you can use this library in any project or framework.

169.2k](/packages/dropfan-onesignal-server-api)[naif/nova-push-notification

A Laravel Nova tool to send push notifications via OneSignal

166.4k](/packages/naif-nova-push-notification)

PHPackages © 2026

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