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

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

constantinosergiou/laravel-onesignal
====================================

OneSignal Push Wrapper Laravel

00PHP

Since Mar 17Pushed 2y agoCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

OneSignal Push Notifications for Laravel
========================================

[](#onesignal-push-notifications-for-laravel)

[![Latest Stable Version](https://camo.githubusercontent.com/9a97e2908137a33dc8ce3989ef6903f48a9d53bbf847d3eb1cb44e81c92e2255/68747470733a2f2f706f7365722e707567782e6f72672f6265726b61796b2f6f6e657369676e616c2d6c61726176656c2f762f737461626c65)](https://packagist.org/packages/berkayk/onesignal-laravel)[![Total Downloads](https://camo.githubusercontent.com/5ec33568c8e26a3a8967c732cd55f7f433e4d19bdf3878004eacb5c8429f03ed/68747470733a2f2f706f7365722e707567782e6f72672f6265726b61796b2f6f6e657369676e616c2d6c61726176656c2f646f776e6c6f616473)](https://packagist.org/packages/berkayk/onesignal-laravel)[![License](https://camo.githubusercontent.com/2e05dbd81b9967239fe69a557ab792cc1de09efdfe42e0aa18ebb35781561260/68747470733a2f2f706f7365722e707567782e6f72672f6265726b61796b2f6f6e657369676e616c2d6c61726176656c2f6c6963656e7365)](https://packagist.org/packages/berkayk/onesignal-laravel)

Introduction
------------

[](#introduction)

This is a simple OneSignal wrapper library for Laravel. It simplifies the basic notification flow with the defined methods. You can send a message to all users or you can notify a single user. Before you start installing this service, please complete your OneSignal setup at  and finish all the steps that is necessary to obtain an application id and REST API Keys.

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

[](#installation)

First, you'll need to require the package with Composer:

```
composer require berkayk/onesignal-laravel
```

Afterwards, run `composer update` from your command line.

**You only need to do the following if your Laravel version is below 5.5**:

Then, update `config/app.php` by adding an entry for the service provider.

```
'providers' => [
	// ...
	Berkayk\OneSignal\OneSignalServiceProvider::class
];
```

Then, register class alias by adding an entry in aliases section

```
'aliases' => [
	// ...
	'OneSignal' => Berkayk\OneSignal\OneSignalFacade::class
];
```

Finally, from the command line again, run

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

```

to publish the default configuration file. This will publish a configuration file named `onesignal.php` which includes your OneSignal authorization keys.

> **Note:** If the previous command does not publish the config file successfully, please check the steps involving *providers* and *aliases* in the `config/app.php` file.

Configuration
-------------

[](#configuration)

You need to fill in your OneSignal *App ID* and *REST API Key* inside your .env file like this:

```
ONESIGNAL_APP_ID=xxxxxxxxxxxxxxxxxxxx
ONESIGNAL_REST_API_KEY=xxxxxxxxxxxxxxxxxx

```

You can control timeout of the Guzzle client used by OneSignalClient by adding following into your .env file

```
ONESIGNAL_GUZZLE_CLIENT_TIMEOUT=integer_value

```

This param is useful when you are planning to send push notification via [Laravel queues](https://divinglaravel.com/always-set-a-timeout-for-guzzle-requests-inside-a-queued-job)

Usage
-----

[](#usage)

### Sending a Notification To All Users

[](#sending-a-notification-to-all-users)

You can easily send a message to all registered users with the command

```
    OneSignal::sendNotificationToAll(
        "Some Message",
        $url = null,
        $data = null,
        $buttons = null,
        $schedule = null
    );
```

`$url` , `$data` , `$buttons` and `$schedule` fields are optional. If you provide a `$url` parameter, users will be redirected to that url.

### Sending a Notification based on Tags/Filters

[](#sending-a-notification-based-on-tagsfilters)

You can send a message based on a set of tags with the command

##### Example 1:

[](#example-1)

```
    OneSignal::sendNotificationUsingTags(
        "Some Message",
        array(
            ["field" => "tag", "key" => "email", "relation" => "=", "value" => "email21@example.com"],
            ["field" => "tag", "key" => "email", "relation" => "=", "value" => "email1@example.com"],
            ...
        ),
        $url = null,
        $data = null,
        $buttons = null,
        $schedule = null
    );
```

##### Example 2:

[](#example-2)

```
    OneSignal::sendNotificationUsingTags(
        "Some Message",
        array(
            ["field" => "tag", "key" => "session_count", "relation" => ">", "value" => '2'],
            ["field" => "tag", "key" => "first_session", "relation" => ">", "value" => '2000'],
        ),
        $url = null,
        $data = null,
        $buttons = null,
        $schedule = null
    );
```

### Sending a Notification To A Specific User

[](#sending-a-notification-to-a-specific-user)

After storing a user's token in a table, you can simply send a message with

```
    OneSignal::sendNotificationToUser(
        "Some Message",
        $userId,
        $url = null,
        $data = null,
        $buttons = null,
        $schedule = null
    );
```

`$userId` is the user's unique id where he/she is registered for notifications. Read  for additional details. `$url` , `$data` , `$buttons` and `$schedule` fields are optional. If you provide a `$url` parameter, users will be redirected to that url.

### Sending a Notification To A Specific external User (custom user id added by user)

[](#sending-a-notification-to-a-specific-external-user-custom-user-id-added-by-user)

After storing a user's token in a table, you can simply send a message with

```
    OneSignal::sendNotificationToExternalUser(
        "Some Message",
        $userId,
        $url = null,
        $data = null,
        $buttons = null,
        $schedule = null
    );
```

`$userId` is the user's unique external id (custom id) added by the user where he/she is registered for notifications. Read  for additional details. `$url` , `$data` , `$buttons` and `$schedule` fields are exceptional. If you provide a `$url` parameter, users will be redirected to that url.

### Sending a Notification To Segment

[](#sending-a-notification-to-segment)

You can simply send a notification to a specific segment with

```
    OneSignal::sendNotificationToSegment(
        "Some Message",
        $segment,
        $url = null,
        $data = null,
        $buttons = null,
        $schedule = null
    );
```

`$url` , `$data` , `$buttons` and `$schedule` fields are optional. If you provide a `$url` parameter, users will be redirected to that url.

### Sending a Custom Notification

[](#sending-a-custom-notification)

You can send a custom message with

```
    OneSignal::sendNotificationCustom($parameters);
```

### Sending a async Custom Notification

[](#sending-a-async-custom-notification)

You can send a async custom message with

```
    OneSignal::async()->sendNotificationCustom($parameters);
```

Please refer to  for all customizable parameters.

Examples
--------

[](#examples)

Some people found examples confusing, so I am going to provide some detailed examples that I use in my applications. These examples will probably guide you on customizing your notifications. For custom parameters, please refer to .

### 1) Sending a message to a segment with custom icon and custom icon color

[](#1-sending-a-message-to-a-segment-with-custom-icon-and-custom-icon-color)

You need to customize `android_accent_color` and `small_icon` values before sending your notifications. These are `parameters` that you need to specify while sending your notifications.

```
use OneSignal;

$params = [];
$params['android_accent_color'] = 'FFCCAA72'; // argb color value
$params['small_icon'] = 'ic_stat_distriqt_default'; // icon res name specified in your app

$message = "Test message to send";
$segment = "Testers";
OneSignal::addParams($params)->sendNotificationToSegment(
                $message,
                $segment
            );

// or to all users
OneSignal::addParams($params)->sendNotificationToAll($message);
```

### 2. Sending a message with high priority

[](#2-sending-a-message-with-high-priority)

This time, we will specify parameters one after the other.

```
use OneSignal;

$message = "Test message to send";
$segment = "Testers";
OneSignal::setParam('priority', 10)->sendNotificationToSegment(
                $message,
                $segment
            );

// You can chain as many parameters as you wish

OneSignal::setParam('priority', 10)->setParam('small_icon', 'ic_stat_onesignal_default')->setParam('led_color', 'FFAACCAA')->sendNotificationToAll($message);
```

### 3. Sending a message with custom heading and subtitle

[](#3-sending-a-message-with-custom-heading-and-subtitle)

```
use OneSignal;

OneSignal::sendNotificationToSegment(
                "Test message with custom heading and subtitle",
                "Testers",
                null, null, null, null,
                "Custom Heading",
                "Custom subtitle"
            );
```

### 4. Sending a delayed message to a specific user with many custom parameters

[](#4-sending-a-delayed-message-to-a-specific-user-with-many-custom-parameters)

```
use OneSignal;

$userId = "3232331-1722-4fee-943d-23123asda123";
$params = [];
$params['include_player_ids'] = [$userId];
$contents = [
   "en" => "Some English Message",
   "tr" => "Some Turkish Message"
];
$params['contents'] = $contents;
$params['delayed_option'] = "timezone"; // Will deliver on user's timezone
$params['delivery_time_of_day'] = "2:30PM"; // Delivery time

OneSignal::sendNotificationCustom($params);
```

###  Health Score

14

—

LowBetter than 2% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity19

Early-stage or recently created project

 Bus Factor1

Top contributor holds 55.3% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/7de8f7e3b35b4731ba486641db9dde292f72c32a881e1bda727798da8cb61708?d=identicon)[coustas83](/maintainers/coustas83)

---

Top Contributors

[![berkayk](https://avatars.githubusercontent.com/u/603844?v=4)](https://github.com/berkayk "berkayk (68 commits)")[![Maykonn](https://avatars.githubusercontent.com/u/1479805?v=4)](https://github.com/Maykonn "Maykonn (8 commits)")[![Mohammad-Alavi](https://avatars.githubusercontent.com/u/24431504?v=4)](https://github.com/Mohammad-Alavi "Mohammad-Alavi (4 commits)")[![stephenjude](https://avatars.githubusercontent.com/u/31182887?v=4)](https://github.com/stephenjude "stephenjude (4 commits)")[![ckin-loox](https://avatars.githubusercontent.com/u/154812537?v=4)](https://github.com/ckin-loox "ckin-loox (4 commits)")[![mbardelmeijer](https://avatars.githubusercontent.com/u/1583095?v=4)](https://github.com/mbardelmeijer "mbardelmeijer (3 commits)")[![constantinosergiou](https://avatars.githubusercontent.com/u/23071921?v=4)](https://github.com/constantinosergiou "constantinosergiou (3 commits)")[![tomaszthreadable](https://avatars.githubusercontent.com/u/104568425?v=4)](https://github.com/tomaszthreadable "tomaszthreadable (3 commits)")[![ksvendsen](https://avatars.githubusercontent.com/u/302771?v=4)](https://github.com/ksvendsen "ksvendsen (2 commits)")[![Chathula](https://avatars.githubusercontent.com/u/4932296?v=4)](https://github.com/Chathula "Chathula (2 commits)")[![MatheusNaldi](https://avatars.githubusercontent.com/u/16821957?v=4)](https://github.com/MatheusNaldi "MatheusNaldi (2 commits)")[![philipnjuguna66](https://avatars.githubusercontent.com/u/25553923?v=4)](https://github.com/philipnjuguna66 "philipnjuguna66 (2 commits)")[![pedro-santiago](https://avatars.githubusercontent.com/u/6331494?v=4)](https://github.com/pedro-santiago "pedro-santiago (1 commits)")[![phfoxer](https://avatars.githubusercontent.com/u/5194383?v=4)](https://github.com/phfoxer "phfoxer (1 commits)")[![ryanedgar](https://avatars.githubusercontent.com/u/7726735?v=4)](https://github.com/ryanedgar "ryanedgar (1 commits)")[![samundra](https://avatars.githubusercontent.com/u/760855?v=4)](https://github.com/samundra "samundra (1 commits)")[![Sml995](https://avatars.githubusercontent.com/u/16786173?v=4)](https://github.com/Sml995 "Sml995 (1 commits)")[![appwebueno](https://avatars.githubusercontent.com/u/262824476?v=4)](https://github.com/appwebueno "appwebueno (1 commits)")[![zzeebbii](https://avatars.githubusercontent.com/u/16489712?v=4)](https://github.com/zzeebbii "zzeebbii (1 commits)")[![aykutfarsak](https://avatars.githubusercontent.com/u/311125?v=4)](https://github.com/aykutfarsak "aykutfarsak (1 commits)")

### Embed Badge

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

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

###  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)
