Skip to content

Commit 418484f

Browse files
committed
init commit 🏗
0 parents  commit 418484f

File tree

8 files changed

+708
-0
lines changed

8 files changed

+708
-0
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.idea/
2+
vendor/
3+
composer.lock
4+
.php_cs.cache
5+
.DS_Store
6+
.env

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016 Mohamed Kawsara - Liliom <m.kawsara@liliom.co>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

README.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# OneSignal Push Notifications for Laravel 5
2+
3+
## Introduction
4+
5+
This is a simple OneSignal wrapper library for Laravel. It simplifies the basic notification flow with the defined methods. You can send a message to all users or you can notify a single user.
6+
Before you start installing this service, please complete your OneSignal setup at https://onesignal.com and finish all the steps that is necessary to obtain an application id and REST API Keys.
7+
8+
9+
## Installation
10+
11+
First, you'll need to require the package with Composer:
12+
13+
```sh
14+
composer require Liliom/onesignal-laravel
15+
```
16+
17+
Aftwards, run `composer update` from your command line.
18+
19+
Then, update `config/app.php` by adding an entry for the service provider.
20+
21+
```php
22+
'providers' => [
23+
// ...
24+
Liliom\OneSignal\OneSignalServiceProvider::class
25+
];
26+
```
27+
28+
29+
Then, register class alias by adding an entry in aliases section
30+
31+
```php
32+
'aliases' => [
33+
// ...
34+
'OneSignal' => Liliom\OneSignal\OneSignalFacade::class
35+
];
36+
```
37+
38+
39+
Finally, from the command line again, run
40+
41+
```
42+
php artisan vendor:publish --tag=config
43+
```
44+
45+
to publish the default configuration file.
46+
This will publish a configuration file named `onesignal.php` which includes your OneSignal authorization keys.
47+
48+
> **Note:** If the previous command does not publish the config file successfully, please check the steps involving *providers* and *aliases* in the `config/app.php` file.
49+
50+
51+
## Configuration
52+
53+
You need to fill in `onesignal.php` file that is found in your applications `config` directory.
54+
`app_id` is your *OneSignal App ID* and `rest_api_key` is your *REST API Key*.
55+
56+
## Usage
57+
58+
### Sending a Notification To All Users
59+
60+
You can easily send a message to all registered users with the command
61+
62+
OneSignal::sendNotificationToAll("Some Message", $url = null, $data = null, $buttons = null, $schedule = null);
63+
64+
`$url` , `$data` , `$buttons` and `$schedule` fields are exceptional. If you provide a `$url` parameter, users will be redirecting to that url.
65+
66+
67+
### Sending a Notification based on Tags/Filters
68+
69+
You can send a message based on a set of tags with the command
70+
71+
OneSignal::sendNotificationUsingTags("Some Message", array("key" => "device_uuid", "relation" => "=", "value" => 123e4567-e89b-12d3-a456-426655440000), $url = null, $data = null, $buttons = null, $schedule = null);
72+
73+
74+
### Sending a Notification To A Specific User
75+
76+
After storing a user's tokens in a table, you can simply send a message with
77+
78+
OneSignal::sendNotificationToUser("Some Message", $userId, $url = null, $data = null, $buttons = null, $schedule = null);
79+
80+
`$userId` is the user's unique id where he/she is registered for notifications. Read https://documentation.onesignal.com/docs/web-push-tagging-guide for additional details.
81+
`$url` , `$data` , `$buttons` and `$schedule` fields are exceptional. If you provide a `$url` parameter, users will be redirecting to that url.
82+
83+
84+
### Sending a Notification To Segment
85+
86+
You can simply send a notification to a specific segment with
87+
88+
OneSignal::sendNotificationToSegment("Some Message", $segment, $url = null, $data = null, $buttons = null, $schedule = null);
89+
90+
`$url` , `$data` , `$buttons` and `$schedule` fields are exceptional. If you provide a `$url` parameter, users will be redirecting to that url.
91+
92+
### Sending a Custom Notification
93+
94+
You can send a custom message with
95+
96+
OneSignal::sendNotificationCustom($parameters);
97+
98+
### Sending a Custom Notification
99+
### Sending a async Custom Notification
100+
You can send a async custom message with
101+
102+
OneSignal::async()->sendNotificationCustom($parameters);
103+
104+
Please refer to https://documentation.onesignal.com/reference for all customizable parameters.
105+

composer.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "liliom/laravel-onesignal",
3+
"description": "Laravel Wrapper for OneSignal Web API",
4+
"keywords": [
5+
"onesignal",
6+
"one signal",
7+
"webpush",
8+
"server side notification",
9+
"push",
10+
"laravel",
11+
"laravel 5"
12+
],
13+
"type": "library",
14+
"require": {
15+
"php": ">=5.5.9",
16+
"guzzlehttp/guzzle": "^6.2",
17+
"illuminate/support": "4.*|5.*",
18+
"symfony/psr-http-message-bridge": "1.*"
19+
},
20+
"require-dev": {
21+
"laravel/laravel": "5.*",
22+
"vlucas/phpdotenv": "^2.2"
23+
},
24+
"license": "MIT",
25+
"authors": [
26+
{
27+
"name": "Mohamed Kawsara",
28+
"email": "mkwsra@gmail.com",
29+
"homepage": "http://mkwsra.com"
30+
},
31+
{
32+
"name": "Hussam Abd",
33+
"email": "hussam3bd@gmail.com"
34+
}
35+
],
36+
"autoload": {
37+
"psr-4": {
38+
"Liliom\\OneSignal\\": "src/"
39+
}
40+
},
41+
"minimum-stability": "stable",
42+
"prefer-stable": true
43+
}

config/onesignal.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
return [
4+
/*
5+
|--------------------------------------------------------------------------
6+
| OneSignal App ID
7+
|--------------------------------------------------------------------------
8+
|
9+
|
10+
*/
11+
'app_id' => env('ONE_SIGNAL_APP_ID', ''),
12+
13+
/*
14+
|--------------------------------------------------------------------------
15+
| Rest API Key
16+
|--------------------------------------------------------------------------
17+
|
18+
|
19+
|
20+
*/
21+
'rest_api_key' => env('ONE_SIGNAL_REST_API_KEY', ''),
22+
'user_auth_key' => env('ONE_SIGNAL_USER_AUTH_KEY', '')
23+
];

0 commit comments

Comments
 (0)