PHPackages                             hafizhassan/onesig-laravel - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. hafizhassan/onesig-laravel

ActiveLibrary[HTTP &amp; Networking](/categories/http)

hafizhassan/onesig-laravel
==========================

OneSignal Push Wrapper Laravel

010PHP

Since Jun 22Pushed 4y ago1 watchersCompare

[ Source](https://github.com/hafizhassan/onesig)[ Packagist](https://packagist.org/packages/hafizhassan/onesig-laravel)[ RSS](/packages/hafizhassan-onesig-laravel/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

Forked from berkayk/laravel-onesignal fix for laravel 7.3 cannot composer install

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 hafizhassan/onesig-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' => [
	// ...
	Hafizhassan\OneSignal\OneSignalServiceProvider::class
];
```

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

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

Finally, from the command line again, run

```
php artisan vendor:publish --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 `onesignal.php` file that is found in your applications `config` directory. `app_id` is your *OneSignal App ID* and `rest_api_key` is your *REST API Key*.

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 exceptional. If you provide a `$url` parameter, users will be redirecting 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(
            ["key" => "email", "relation" => "=", "value" => "email21@example.com"],
            ["key" => "email", "relation" => "=", "value" => "email1@example.com"],
            ...
        ),
        $url = null,
        $data = null,
        $buttons = null,
        $schedule = null
    );
```

##### Example 2:

[](#example-2)

```
    OneSignal::sendNotificationUsingTags(
        "Some Message",
        array(
            ["key" => "session_count", "relation" => ">", "value" => '2'],
            ["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 tokens 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 exceptional. If you provide a `$url` parameter, users will be redirecting 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 tokens 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 redirecting 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 exceptional. If you provide a `$url` parameter, users will be redirecting 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.

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity29

Early-stage or recently created project

 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.

### Community

Maintainers

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

---

Top Contributors

[![hafizhassan](https://avatars.githubusercontent.com/u/4852934?v=4)](https://github.com/hafizhassan "hafizhassan (16 commits)")

### Embed Badge

![Health badge](/badges/hafizhassan-onesig-laravel/health.svg)

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

###  Alternatives

[friendsofsymfony/rest-bundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony

2.8k73.3M319](/packages/friendsofsymfony-rest-bundle)[php-http/discovery

Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations

1.3k309.5M1.2k](/packages/php-http-discovery)[nyholm/psr7

A fast PHP7 implementation of PSR-7

1.3k235.4M2.4k](/packages/nyholm-psr7)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M293](/packages/pusher-pusher-php-server)[spatie/crawler

Crawl all internal links found on a website

2.8k16.3M52](/packages/spatie-crawler)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78126.4M414](/packages/react-http)

PHPackages © 2026

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