https://github.com/lordjoo/onesignal-php
This is a php laravel , composer library for implementing OneSignal push notifications
https://github.com/lordjoo/onesignal-php
composer laravel onesignal php php-library pushnotifications
Last synced: 5 months ago
JSON representation
This is a php laravel , composer library for implementing OneSignal push notifications
- Host: GitHub
- URL: https://github.com/lordjoo/onesignal-php
- Owner: lordjoo
- Created: 2019-04-09T14:11:47.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-08-18T23:48:20.000Z (almost 7 years ago)
- Last Synced: 2026-01-11T12:44:01.579Z (6 months ago)
- Topics: composer, laravel, onesignal, php, php-library, pushnotifications
- Language: PHP
- Homepage:
- Size: 19.5 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# OneSignal PHP Library
###### This PHP Library help You Integrate OneSignal Push Notification Easily in your website
> This Library Supports Laravel Framework
## Features
##### Two Ways You Can Send The Notification
* Send Notification To all Subscribed Users
* Send To Specific User
* Send To Segment
------------
#### Notification Features
* Send With Custom Logo icons (Required)
* Send With Large Image (Optional)
* Send With Custom Badge (Optional)
* Send With Unlimited Customized Buttons (Optional)
------------
### Installation
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
#### Laravel Only
Publish the Config File For The Library
```
php artisan vendor:publish --tag=config
```
### How To Use It ?
Requiring And Initialize The Library
```php
```
The Properties to change
| Property Name | Is Required | The Value |
| ------------ | ------------ | ------------ |
| $heading | :ballot_box_with_check: | The Title Heading With language code in array ` $notification->heading = ["en"=>"hello World !","ar"=>"مرحبا بالعالم"] ` |
| $content | :ballot_box_with_check: | The Notification Body With language code like the `$heading` |
| $logo | :ballot_box_with_check: | 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](https://documentation.onesignal.com/reference#section-action-buttons "The Official Docs") |
| $badge | -- | The Notification Bage Icon Url `string` |
------
##### EX1: Send To All Users
```php
$notification->sendToAll(); // This Will Reqturn A JSON With The Response From OneSginal
```
##### EX2: Send To Specific User
```php
$notification->sendToSpecific($userSuscribtionID); // This Will Reqturn A JSON With The Response From OneSginal
```
##### EX3: Send To Custom Segments
```php
$notification->sendToSegment($segmentsArray); // This Will Reqturn A JSON With The Response From OneSginal
```
## To Do
* [ ] Fix Buttons Format Error
* [ ] Add Send To Multi Users By IDs
* [*] Add Unit Test
* [*] Handle Exceptions
* [ ] Add Send To Custom Devices