A Laravel package for seamless integration with OneSignal push notification service.
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.
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"
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.
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.
use AwaluddinKasim\OneSignalPushNotification\OneSignal;
OneSignal::sendToAll($your_message);
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.
This package is released under the MIT License.