Skip to content

Commit 027a54d

Browse files
authored
Merge pull request #29 from baggednismo/patch
Added priority variable to set when sending a new notification
2 parents abd6a13 + 2ae3f39 commit 027a54d

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

readme.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@ A simple package that help you send a Firebase notification with your Laravel ap
66

77
You can pull the package via composer :
88

9-
``` bash
9+
```bash
1010
$ composer require kawankoding/laravel-fcm
1111
```
1212

13-
Next, You must register the service provider :
13+
Next, You must register the service provider :
1414

15-
```php
15+
```php
1616
// config/app.php
1717

1818
'Providers' => [
19-
// ...
20-
Kawankoding\Fcm\FcmServiceProvider::class,
19+
// ...
20+
Kawankoding\Fcm\FcmServiceProvider::class,
2121
]
22-
```
22+
```
2323

24-
If you want to make use of the facade you must install it as well :
24+
If you want to make use of the facade you must install it as well :
2525

2626
```php
2727
// config/app.php
@@ -54,6 +54,7 @@ return [
5454
```
5555

5656
Set your FCM Server Key in `.env` file :
57+
5758
```
5859
APP_NAME="Laravel"
5960
# ...
@@ -63,20 +64,24 @@ FCM_SERVER_KEY=putYourKeyHere
6364
### Usage
6465

6566
If You want to send a FCM with just notification parameter, this is an example of usage sending a FCM with only data parameter :
67+
6668
```php
6769
fcm()
6870
->to($recipients) // $recipients must an array
71+
->priority('high')
6972
->data([
7073
'title' => 'Test FCM',
7174
'body' => 'This is a test of FCM',
7275
])
7376
->send();
7477
```
7578

76-
If You want to send a FCM to topic, use method toTopic($topic) instead to() :
79+
If You want to send a FCM to topic, use method toTopic(\$topic) instead to() :
80+
7781
```php
7882
fcm()
7983
->toTopic($topic) // $topic must an string (topic name)
84+
->priority('normal')
8085
->notification([
8186
'title' => 'Test FCM',
8287
'body' => 'This is a test of FCM',
@@ -85,9 +90,11 @@ fcm()
8590
```
8691

8792
If You want to send a FCM with just notification parameter, this is an example of usage sending a FCM with only notification parameter :
93+
8894
```php
8995
fcm()
9096
->to($recipients) // $recipients must an array
97+
->priority('high')
9198
->notification([
9299
'title' => 'Test FCM',
93100
'body' => 'This is a test of FCM',
@@ -96,9 +103,11 @@ fcm()
96103
```
97104

98105
If You want to send a FCM with both data & notification parameter, this is an example of usage sending a FCM with both data & notification parameter :
106+
99107
```php
100108
fcm()
101109
->to($recipients) // $recipients must an array
110+
->priority('normal')
102111
->data([
103112
'title' => 'Test FCM',
104113
'body' => 'This is a test of FCM',

src/Fcm.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class Fcm
1313
protected $data;
1414
protected $notification;
1515
protected $timeToLive;
16+
protected $priority;
1617

1718
public function to(array $recipients)
1819
{
@@ -42,6 +43,13 @@ public function notification(array $notification = [])
4243
return $this;
4344
}
4445

46+
public function priority(string $priority)
47+
{
48+
$this->priority = $priority;
49+
50+
return $this;
51+
}
52+
4553
public function timeToLive(int $timeToLive)
4654
{
4755
if ($timeToLive < 0) {
@@ -62,7 +70,7 @@ public function send()
6270

6371
$payloads = [
6472
'content_available' => true,
65-
'priority' => 'high',
73+
'priority' => $this->priority,
6674
'data' => $this->data,
6775
'notification' => $this->notification
6876
];

0 commit comments

Comments
 (0)