Skip to content

Commit 3c976d1

Browse files
Merge pull request #1 from kawankoding/master
Merge
2 parents c4f703b + e8879f0 commit 3c976d1

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-5
lines changed

readme.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ You can pull the package via composer :
1010
$ composer require kawankoding/laravel-fcm "^0.2.0"
1111
```
1212

13-
Next, You must register the service provider :
13+
#### Laravel
14+
15+
You must register the service provider :
1416

1517
```php
1618
// config/app.php
@@ -53,6 +55,24 @@ return [
5355
];
5456
```
5557

58+
#### Lumen
59+
60+
Add the following service provider to the `bootstrap/app.php` file
61+
```php
62+
$app->register(Kawankoding\Fcm\FcmServiceProvider::class);
63+
```
64+
65+
Also copy the [laravel-fcm.php](https://github.com/kawankoding/laravel-fcm/blob/master/resources/config/laravel-fcm.php) config file to `config/laravel-fcm.php`
66+
67+
68+
Add the configuration to the `bootstrap/app.php` file
69+
*Important:* this needs to be before the registration of the service provider
70+
```php
71+
$app->configure('laravel-fcm');
72+
...
73+
$app->register(Kawankoding\Fcm\FcmServiceProvider::class);
74+
```
75+
5676
Set your FCM Server Key in `.env` file :
5777

5878
```
@@ -66,8 +86,13 @@ FCM_SERVER_KEY=putYourKeyHere
6686
If You want to send a FCM with just notification parameter, this is an example of usage sending a FCM with only data parameter :
6787

6888
```php
89+
$recipients = [
90+
'clKMv.......',
91+
'GxQQW.......',
92+
];
93+
6994
fcm()
70-
->to($recipients) // $recipients must an array
95+
->to($recipients)
7196
->priority('high')
7297
->timeToLive(0)
7398
->data([

src/FcmServiceProvider.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
namespace Kawankoding\Fcm;
44

5+
use Illuminate\Foundation\Application as LaravelApplication;
56
use Illuminate\Support\ServiceProvider;
67
use Kawankoding\Fcm\Fcm;
8+
use Laravel\Lumen\Application as LumenApplication;
79

810
/**
911
* Class FcmServiceProvider
@@ -13,9 +15,13 @@ class FcmServiceProvider extends ServiceProvider
1315
{
1416
public function boot()
1517
{
16-
$this->publishes([
17-
__DIR__ . '/../resources/config/laravel-fcm.php' => config_path('laravel-fcm.php'),
18-
]);
18+
if ($this->app instanceof LaravelApplication && $this->app->runningInConsole()) {
19+
$this->publishes([
20+
__DIR__ . '/../resources/config/laravel-fcm.php' => config_path('laravel-fcm.php'),
21+
]);
22+
} elseif ($this->app instanceof LumenApplication) {
23+
$this->app->configure('laravel-fcm');
24+
}
1925
}
2026

2127
public function register()

0 commit comments

Comments
 (0)