Skip to content

Commit f22749b

Browse files
committed
add FCMB facade
1 parent 0237e2a commit f22749b

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

src/Facades/FCMBatch.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace Quantomtech\LaravelFirebaseBatchMessaging\Facades;
4+
5+
use Illuminate\Support\Facades\Facade;
6+
7+
/**
8+
* @method static \Quantomtech\LaravelFirebaseBatchMessaging\FCMBatch addPayload(string $fcmToken, string $title, string $body, array $data = null, bool $IosPayload = false)
9+
* @method static \Quantomtech\LaravelFirebaseBatchMessaging\FCMBatch addCustomPayload(array $payload)
10+
* @method static \Illuminate\Http\Client\Response send()
11+
* @method static string getAccessToken()
12+
* @method static string createJWTToken(string $periodSeconds=3600)
13+
*
14+
* @see \Quantomtech\LaravelFirebaseBatchMessaging\FCMBatch
15+
*/
16+
class FCMBatch extends Facade
17+
{
18+
protected static function getFacadeAccessor()
19+
{
20+
return 'qt.fcm.batch';
21+
}
22+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
namespace Quantomtech\LaravelFirebaseBatchMessaging\Providers;
4+
5+
use Illuminate\Support\ServiceProvider;
6+
use Quantomtech\LaravelFirebaseBatchMessaging\FCMBatch;
7+
8+
class FCMBatchServiceProvider extends ServiceProvider
9+
{
10+
/**
11+
* Register services.
12+
*
13+
* @return void
14+
*/
15+
public function register()
16+
{
17+
/*
18+
* Function not available and 'publish' not relevant in Lumen
19+
*
20+
*/
21+
if (function_exists('config_path')) {
22+
23+
$this->mergeConfigFrom(__DIR__.'/../config/fcm-batch.php', 'fcm-batch');
24+
}
25+
26+
/*
27+
* Register the service the package provides.
28+
*
29+
*/
30+
$this->app->singleton('qt.fcm.batch', function () {
31+
return new FCMBatch;
32+
});
33+
}
34+
35+
36+
/**
37+
* Bootstrap services.
38+
*
39+
* @return void
40+
*/
41+
public function boot()
42+
{
43+
$this->publishes([
44+
__DIR__.'/../config/fcm-batch.php' => config_path('fcm-batch.php'),
45+
], 'config');
46+
}
47+
}

0 commit comments

Comments
 (0)