Skip to content

A Laravel package for seamless integration with OneSignal push notification service

License

Notifications You must be signed in to change notification settings

awaluddinkasim/onesignal-pushnotification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OneSignal Push Notification

A Laravel package for seamless integration with OneSignal push notification service.

Latest Stable Version License PHP Version Require

Introduction

OneSignal is a platform that offers multiple messaging channels including mobile push notifications, web push, SMS, email, and in-app messaging. This Laravel package specifically focuses on implementing push notifications functionality from OneSignal's services into your Laravel application. Check out the documentation for more information about OneSignal.

Installation

To install this package, simply run the following command:

composer require awaluddinkasim/onesignal-pushnotification

Next, run the this command to publish the configuration file:

php artisan vendor:publish --provider="AwaluddinKasim\OneSignalPushNotification\OneSignalServiceProvider"

Usage

Add your OneSignal App ID and API Key to your .env file:

ONESIGNAL_APP_ID=xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
ONESIGNAL_API_KEY=xx_xx_xxx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Check here for more information about App ID and API Key.

Note

Starting November 14 2024, OneSignal has implemented a new Rich API key system and is deprecating legacy API keys. This package is updated to use the new Rich API key system.

Send a push notification to all users:

use AwaluddinKasim\OneSignalPushNotification\OneSignal;

OneSignal::sendToAll($your_message); 

Send a push notification to a user by external user ID:

use AwaluddinKasim\OneSignalPushNotification\OneSignal;

OneSignal::sendToUser($external_user_id, $your_message);

$external_user_id can be a string or an array of strings. If an array is given, all the given IDs will receive the notification.

You can read more about External ID here.

License

This package is released under the MIT License.