awaluddinkasim/onesignal-pushnotification

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

v1.0.3 2024-11-15 07:14 UTC

This package is auto-updated.

Last update: 2024-11-16 07:38:45 UTC


README

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.