PHPackages                             mprince/one-signal - 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. [API Development](/categories/api)
4. /
5. mprince/one-signal

ActiveLibrary[API Development](/categories/api)

mprince/one-signal
==================

Laravel 8+ Wrapper for OneSignal.

01PHP

Since Oct 16Pushed 4y ago1 watchersCompare

[ Source](https://github.com/mprince2k18/larasignal)[ Packagist](https://packagist.org/packages/mprince/one-signal)[ RSS](/packages/mprince-one-signal/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel One Signal
==================

[](#laravel-one-signal)

Laravel One Signal is Laravel Wrapper for [One Signal](https://onesignal.com). One Signal is a great platform for send a push notification to your users.

forked from [One Signal](https://github.com/shailesh-ladumor/one-signal)

Contents
--------

[](#contents)

- [Installation](#installation)
    - [Publish the config file](#publish-the-config-file)
    - [Add Provider](#add-provider)
    - [Add Facade](#add-facade)
- [Usage](#usage)
    - [Send Push Notification](#send-push-notification)
    - [Cancel Notification](#cancel-notification)
    - [Customise Contents](#customise-contents)
    - [Get All Notifications](#get-all-notifications)
    - [Get Single Notification](#get-single-notification)
    - [Get All Devices](#get-all-devices)
    - [Get Single Device](#get-single-device)
    - [Create Device](#get-single-device)
    - [Update Device](#update-device)
    - [Create Segment (NEED PAID PLAN)](#create-segment)
    - [Delete Segment (NEED PAID PLAN)](#delete-segment)
    - [View Apps](#view-apps)
    - [View App](#view-app)
    - [Create App](#create-app)
    - [Update App](#update-app)
- [User Device](#user-device)
- [Change Log](#change-log)
- [License](#license)

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

[](#installation)

Install the package by the following command,

```
composer require mprince/one-signal

```

Publish the config file
-----------------------

[](#publish-the-config-file)

Run the following command to publish config file,

```
php artisan vendor:publish --provider="Ladumor\OneSignal\OneSignalServiceProvider"

```

Add Provider
------------

[](#add-provider)

Add the provider to your `config/app.php` into `provider` section if using lower version of laravel,

```
Ladumor\OneSignal\OneSignalServiceProvider::class,

```

Add Facade
----------

[](#add-facade)

Add the Facade to your `config/app.php` into `aliases` section,

```
'OneSignal' => \Ladumor\OneSignal\OneSignal::class,

```

Add ENV data
------------

[](#add-env-data)

Add your api keys and OneSignal app id to your `.env`,

```
ONE_SIGNAL_APP_ID=XXXXXX-XXXXXX-XXXXXX-XXXXXX  (YOUR APP ID)
ONE_SIGNAL_AUTHORIZE=XXXXXX                    (REST API KEY)
ONE_SIGNAL_AUTH_KEY=XXXXXXX                    (YOUR USER AUTH KEY)

```

You can call them into your code with,

Usage
-----

[](#usage)

### Send Push Notification

[](#send-push-notification)

For send push notification, use the sendPush method by calling,

```
$fields['include_player_ids'] = ['xxxxxxxx-xxxx-xxx-xxxx-yyyyyyyyy'];
$message = 'hey!! this is test push.!'

OneSignal::sendPush($fields, $message);

```

Optionally, you can obtain the id of the notification like this,

```
$notificationID = OneSignal::sendPush($fields, $message);
echo $notificationID["id"];

```

### Cancel Notification

[](#cancel-notification)

To cancel a notification, use the cancelNotification method by calling,

```
$notificationID = 'xxxxxxxx-xxxx-xxx-xxxx-yyyyyyyyy';

OneSignal::cancelNotification($notificationID);

```

### Customise Contents

[](#customise-contents)

You can customise a contents and pass it in fields. message does not required when you pass contents

```
$fields['include_player_ids'] = ['xxxxxxxx-xxxx-xxx-xxxx-yyyyyyyyy'];
$fields['contents'] = array(
                          "en" => 'English Message',
                          "es" => 'Spanish Message',
                      );
OneSignal::sendPush($fields);

```

### Get All Notifications

[](#get-all-notifications)

For retrieve all notifications, use the `getNotifications` method by calling,

```
OneSignal::getNotifications();

```

You can check [here](https://documentation.onesignal.com/reference#section-result-format-view-notifications) return response format.

### Get Single Notification

[](#get-single-notification)

For retrieve single notification, use the `getNotification` method with id param by calling,

```
OneSignal::getNotification($notificationId);

```

You can check [here](https://documentation.onesignal.com/reference#section-result-format-view-notification) return response format.

### Get All Devices

[](#get-all-devices)

For retrieve all user devices, use the `getDevices` method by calling,

```
OneSignal::getDevices();

```

You can check [here](https://documentation.onesignal.com/reference#view-devices) return response format.

### Get Single Device

[](#get-single-device)

For retrieve single Devices, use the `getDevice` method with id param by calling,

```
OneSignal::getDevice($deviceId);

```

You can check [here](https://documentation.onesignal.com/reference#view-device) return response format.

### Create Device

[](#create-device)

For add a device in your application, use the `addDevice` method by calling, if you want to create device in different application than you can specify `app_id` in `$fields` array.

```
 $fields = [
        'device_type'  => 0,
        'identifier'   => '7abcd558f29d0b1f048083e2834ad8ea4b3d87d8ad9c088b33c132706ff445f0',
        'timezone'     => '-28800',
        'game_version' => '1.1',
        'device_os'    => '7.0.4',
        'test_type'    => 1,
        'device_model' => "iPhone 8,2",
        'tags'         => array("foo" => "bar")
    ];

 return OneSignal::addDevice($fields);

```

You can check [here](https://documentation.onesignal.com/reference#section-example-code-add-a-device) supported parameters and guide.

### Update Device

[](#update-device)

For update a device in your application, use the `addDevice` method by calling, if you want to update device in different application than you can specify `app_id` in `$fields` array.

```
 $fields = [
        'device_type'  => 0,
        'identifier'   => '7abcd558f29d0b1f048083e2834ad8ea4b3d87d8ad9c088b33c132706ff445f0',
        'timezone'     => '-28800',
        'game_version' => '1.1',
        'device_os'    => '7.0.4',
        'test_type'    => 1,
        'device_model' => "iPhone 8,2",
        'tags'         => array("foo" => "bar")
    ];

 $playerId = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';

 return OneSignal::updateDevice($fields, $playerId);

```

You can check [here](https://documentation.onesignal.com/reference#section-body-parameters) supported parameters and guide.

### Create Segment

[](#create-segment)

#### NOTE: REQUIRED ONE-SIGNAL [PAID PLAN](https://documentation.onesignal.com/docs/paid-plan-benefits)

[](#note-required-one-signal-paid-plan)

For add a new segment in your application, use the `createSegment` method by calling,

```
 $fields = [
         'name' => 'iOS, Android, Web',
         "filters" => array("field" => "device_type", "relation" => "=", "value" => "Android"),
     ];

return OneSignal::createSegment($fields);

```

You can check [here](https://documentation.onesignal.com/reference#create-segments) supported parameters and guide.

```
OneSignal::deleteSegment('YOUR_SEGMENT_ID')

```

### Delete Segment

[](#delete-segment)

#### NOTE: REQUIRED ONE-SIGNAL [PAID PLAN](https://documentation.onesignal.com/docs/paid-plan-benefits)

[](#note-required-one-signal-paid-plan-1)

You can check [here](https://documentation.onesignal.com/reference#delete-segments) for more guide.

Apps
----

[](#apps)

Note\*: `Auth key must be set in one-signal.php` how to get [auth\_key](https://documentation.onesignal.com/docs/accounts-and-keys#section-user-auth-key)?

### View Apps

[](#view-apps)

View the details of all of your current OneSignal apps

```
 $apps = OneSignal::getApps();

```

You can check [here](https://documentation.onesignal.com/reference#view-apps-apps) api response.

### View App

[](#view-app)

View the details of single of your current OneSignal app or other app by passing app id.

```
 // It's return default site which is configured in config.
 $app = OneSignal::getApp();

 // you can specify app id as wel but it's optional
 $app = OneSignal::getApp('YOUR_APP_ID');

```

You can check [here](https://documentation.onesignal.com/reference#view-an-app) api response.

### Create App

[](#create-app)

Creates a new OneSignal app.

```
 $fields = array(
        'name' => "TestByMe"
    );

 OneSignal::createApp($fields);

```

You can check [here](https://documentation.onesignal.com/reference#create-an-app) supported parameters and guide.

### Update App

[](#update-app)

Update a new OneSignal app.

```
 $fields = array(
        'name' => "TestByMe"
    );

 OneSignal::updateApp($fields);
 // you can pass second param as a appId if you want to update other app.. default take from config.

```

You can check [here](https://documentation.onesignal.com/reference#update-an-app) supported parameters and guide.

User Device
-----------

[](#user-device)

[![](https://camo.githubusercontent.com/59feebd3d40fcbb1104a3f554ec3b754f1b37674254fde3b0d8f069c1b1d958b/68747470733a2f2f696d672e796f75747562652e636f6d2f76692f774f483171735133534c382f302e6a7067)](https://youtu.be/wOH1qsQ3SL8)

You can generate a User Device APIs with just one command,

`php artisan one-signal.userDevice:publish`

this command generate following files,

- UserDeviceAPIController
- UserDeviceAPIRepository
- UserDevice (model)
- Migration

Also, do not forget to add following routes in to the `api.php` file.

```
use App\Http\Controllers\API\UserDeviceAPIController;

```

```
  Route::post('user-device/register', [UserDeviceAPIController::class, 'registerDevice']);
  Route::get('user-device/{playerId}/update-status', [UserDeviceAPIController::class, 'updateNotificationStatus']);

```

### Change Log

[](#change-log)

Please see [Change Log](CHANGELOG.md) here

### License

[](#license)

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

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity1

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity28

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://avatars.githubusercontent.com/u/43857625?v=4)[Mohammad Prince](/maintainers/mprince2k18)[@mprince2k18](https://github.com/mprince2k18)

---

Top Contributors

[![mprince2k18](https://avatars.githubusercontent.com/u/43857625?v=4)](https://github.com/mprince2k18 "mprince2k18 (2 commits)")

### Embed Badge

![Health badge](/badges/mprince-one-signal/health.svg)

```
[![Health](https://phpackages.com/badges/mprince-one-signal/health.svg)](https://phpackages.com/packages/mprince-one-signal)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

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