Skip to content

Commit 034cff0

Browse files
authored
Merge pull request #26 from erlangp/patch-7
add ability to set lifetime of messages
2 parents b51084b + ec950aa commit 034cff0

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/Fcm.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class Fcm
1212
protected $topic;
1313
protected $data;
1414
protected $notification;
15+
protected $timeToLive;
1516

1617
public function to(array $recipients)
1718
{
@@ -40,6 +41,13 @@ public function notification(array $notification = [])
4041

4142
return $this;
4243
}
44+
45+
public function timeToLive(int $timeToLive)
46+
{
47+
$this->timeToLive = $timeToLive;
48+
49+
return $this;
50+
}
4351

4452
public function send()
4553
{
@@ -57,6 +65,10 @@ public function send()
5765
} else {
5866
$payloads['registration_ids'] = $this->recipients;
5967
}
68+
69+
if ($this->timeToLive !== null && $this->timeToLive >= 0) {
70+
$payloads['time_to_live'] = (int) $this->timeToLive;
71+
}
6072

6173
$serverKey = config('laravel-fcm.server_key');
6274

0 commit comments

Comments
 (0)