File tree Expand file tree Collapse file tree 2 files changed +36
-5
lines changed Expand file tree Collapse file tree 2 files changed +36
-5
lines changed Original file line number Diff line number Diff 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+
5676Set your FCM Server Key in ` .env ` file :
5777
5878```
@@ -66,8 +86,13 @@ FCM_SERVER_KEY=putYourKeyHere
6686If 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+
6994fcm()
70- ->to($recipients) // $recipients must an array
95+ ->to($recipients)
7196 ->priority('high')
7297 ->timeToLive(0)
7398 ->data([
Original file line number Diff line number Diff line change 22
33namespace Kawankoding \Fcm ;
44
5+ use Illuminate \Foundation \Application as LaravelApplication ;
56use Illuminate \Support \ServiceProvider ;
67use 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 ()
You can’t perform that action at this time.
0 commit comments