Skip to content

Commit e2e5afd

Browse files
authored
Merge pull request #13 from rlems/master
added config file
2 parents 18fe219 + 9b12658 commit e2e5afd

File tree

3 files changed

+43
-4
lines changed

3 files changed

+43
-4
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ class_alias( 'jmrieger\OneSignal\OneSignalFacade', 'OneSignal' );
4141
## Configuration
4242
There are 3 settings that need to be updated: your default OneSignal app ID, the REST API key, and the User Auth Key. All of these items can be found in your Control Panel on the OneSignal site.
4343

44+
First, publish the onesignal config:
45+
```
46+
php artisan vendor:publish
47+
```
48+
4449
Place the 3 keys into your .env file, as such:
4550
```
4651
ONESIGNAL_APP_ID=

config/onesignal.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
return [
4+
/*
5+
|--------------------------------------------------------------------------
6+
| OneSignal App ID
7+
|--------------------------------------------------------------------------
8+
|
9+
| The OneSignal app to send notifications for by default
10+
|
11+
*/
12+
'onesignal_app_id' => env('ONESIGNAL_APP_ID', ''),
13+
14+
/*
15+
|--------------------------------------------------------------------------
16+
| OneSignal REST API Key
17+
|--------------------------------------------------------------------------
18+
|
19+
| The API key to use the OneSignal API
20+
|
21+
*/
22+
'onesignal_rest_api_key' => env('ONESIGNAL_REST_API_KEY', ''),
23+
24+
25+
/*
26+
|--------------------------------------------------------------------------
27+
| OneSignal User Auth Key
28+
|--------------------------------------------------------------------------
29+
|
30+
| A OneSignal User authentication key, used to create apps in OneSignal
31+
|
32+
*/
33+
'onesignal_user_auth_key' => env('ONESIGNAL_USER_AUTH_KEY', ''),
34+
];

src/OneSignalServiceProvider.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ public function boot()
2424
public function register()
2525
{
2626
/** @noinspection PhpUndefinedFieldInspection */
27-
$this->app->singleton('onesignal', function () {
27+
$this->app->singleton('onesignal', function ($app) {
2828
/** @noinspection PhpUndefinedFunctionInspection */
2929
/** @noinspection PhpUndefinedFunctionInspection */
3030
/** @noinspection PhpUndefinedFunctionInspection */
3131
$config = [
32-
"app_id" => (env("ONESIGNAL_APP_ID") ?: ""),
33-
"rest_api_key" => (env("ONESIGNAL_REST_API_KEY") ?: ""),
34-
"user_auth_key" => (env("ONESIGNAL_USER_AUTH_KEY") ?: ""),
32+
"app_id" => $app['config']['onesignal']['onesignal_app_id'],
33+
"rest_api_key" => $app['config']['onesignal']['onesignal_rest_api_key'],
34+
"user_auth_key" => $app['config']['onesignal']['onesignal_user_auth_key'],
3535
];
3636

3737
$client = new OneSignalClient($config[ 'app_id' ], $config[ 'rest_api_key' ], $config[ 'user_auth_key' ]);

0 commit comments

Comments
 (0)