An open API service indexing awesome lists of open source software.

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

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