This Library Supports Laravel Framework
- Send Notification To all Subscribed Users
- Send To Specific User
- Send To Segment
- Send With Custom Logo icons (Required)
- Send With Large Image (Optional)
- Send With Custom Badge (Optional)
- Send With Unlimited Customized Buttons (Optional)
whether you re using laravel or not just install the package wit
composer require youssef20000/onesignal-php
if you are using laravel >= 5.6 The Package will be detected automatically
Publish the Config File For The Library
php artisan vendor:publish --tag=config
Requiring And Initialize The Library
<?php
// Require The Outload File For Composeer
use Youssef\OneSignal\OneSignal;
// if not laravel
$notification = new OneSignal($appID,$apiKEY);
// if laravel the appid and apikey will be obtained from the config file
?>
The Properties to change
Property Name | Is Required | The Value |
---|---|---|
$heading | ☑️ | The Title Heading With language code in array $notification->heading = ["en"=>"hello World !","ar"=>"مرحبا بالعالم"] |
$content | ☑️ | The Notification Body With language code like the $heading |
$logo | ☑️ | The Logo Url String |
$image | -- | The Big Image Url String |
$url | -- | The Action Url That Will Opened String |
$appUrl | -- | If You Have App Url You Want Notification Redirect user To String |
$buttons | -- | The Buttons Array Examples At The Official Docs |
$badge | -- | The Notification Bage Icon Url string |
$notification->sendToAll(); // This Will Reqturn A JSON With The Response From OneSginal
$notification->sendToSpecific($userSuscribtionID); // This Will Reqturn A JSON With The Response From OneSginal
$notification->sendToSegment($segmentsArray); // This Will Reqturn A JSON With The Response From OneSginal
- Fix Buttons Format Error
- Add Send To Multi Users By IDs
- [*] Add Unit Test
- [*] Handle Exceptions
- Add Send To Custom Devices