PHPackages                             okn/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. [API Development](/categories/api)
4. /
5. okn/laravel-onesignal

ActiveLibrary[API Development](/categories/api)

okn/laravel-onesignal
=====================

OneSignal wrapper for Laravel

022PHP

Since May 13Pushed 5y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

OneSignal Push Notifications for Laravel 5+
===========================================

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

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

[](#introduction)

This project, widely inspired by Berkayk (), is another one OneSignal wrapper for Laravel. The main purpose is to make web push notifications easier. Before using this service, you'll need to complete all steps of your OneSignal setup () to get your Application ID and API keys.

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

[](#installation)

1. Require package with composer

```
composer require okn/laravel-onesignal
```

2. **Only for Laravel version &lt; 5.5**
    Add the service provider and class alias for facade support in `config/app.php`

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

'aliases' => [
   	// ...
   	'OneSignal' => Okn\OneSignal\Facades\OneSignal::class
];
```

3. Run artisan command to install the service

```
php artisan onesignal:install
```

This command will create a default config file `config/onesignal.php`.

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

[](#configuration)

App ID et API keys must be defined in the `.env` file as follow:

```
ONESIGNAL_APP_ID=
ONESIGNAL_REST_API_KEY=
ONESIGNAL_USER_AUTH_KEY=
```

Usage
-----

[](#usage)

### Default use

[](#default-use)

1. Create a notification

```
$notification = OneSignal::createNotification([
    'headings'=>'Title',
    'contents'=>'Notification message...',
    'url'=>'https://yourwebsite.com'
]);
```

2. Send notification

- To segment(s)

```
$notification->send(['segments'=>['SEGMENT-NAME']]);
```

- To specific user(s)

```
$notification->send(['ids'=>['PLAYER-ID-1','PLAYER-ID-2','PLAYER-ID-3']]);
```

- Asynchronously

```
$promise = $notification->async()->send([$params]);
```

This will return a `GuzzleHttp\Promise\Promise` ()

### Add buttons to notification

[](#add-buttons-to-notification)

```
$notification->withButtons([
	[
		'id' => 'btnId1',
		'text' => 'Webpush button test',
		'icon' => 'https://yourwebsite.com/images/icon1.png',
		'url' => 'https://yourwebsite.com/action1'
	],
	[
		'id' => 'btnId2',
		'text' => 'Webpush button test #2',
		'icon' => 'https://yourwebsite.com/images/icon2.png',
		'url' => 'https://yourwebsite.com/action2'
	]
])->send([$params]);
```

### Send a default template test notification

[](#send-a-default-template-test-notification)

- To an existing segment named "Admin"

```
OneSignal::test();
```

This method also accepts the same argument as the method `send()`.

### Retrieve Users

[](#retrieve-users)

1. All users

```
OneSignal::getUsers(300, 0);
```

The first argument is the **maximum limit**, and the second is the **offset**. Both are optional.

2. Specific user

```
OneSignal::getUser('PLAYER-ID');
```

Exception(s)
============

[](#exceptions)

`cURL error 60: SSL certificate problem...`
cURL need an SSL certificate to communicate through **https** protocol.

Solution 1 (recommended)
------------------------

[](#solution-1-recommended)

### Install an SSL certificate on your local machine

[](#install-an-ssl-certificate-on-your-local-machine)

Assuming you are using WAMP on Windows:

- download an SSL certificate for your local server
- put it in your prefered directory (mine is `C:\Users\[MY-USERNAME]\cacert.pem`)
- edit this variable in your `php.ini` to add the path to the certificate

```
curl.cainfo = "C:\Users\[MY-USERNAME]\cacert.pem"
```

- restart your webserver

Now it should works, if it doesn't you might try the next solution.

Solution 2
----------

[](#solution-2)

### Disable SSL validation (not recommended)

[](#disable-ssl-validation-not-recommended)

In `.env` file you can add the following line:

```
ONESIGNAL_SSL_VERIFY=false
```

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity30

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/b4d06f7712b61348cc930c5a6294b359577abfba884c0bd1dfe2984d63fc3104?d=identicon)[okn](/maintainers/okn)

---

Top Contributors

[![0kyn](https://avatars.githubusercontent.com/u/29523399?v=4)](https://github.com/0kyn "0kyn (6 commits)")

### Embed Badge

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

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

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