Skip to content

Commit abd6a13

Browse files
authored
Merge pull request #28 from erlangp/patch-8
min & max lifespan of a message
2 parents 034cff0 + 7de8dd7 commit abd6a13

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/Fcm.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,18 @@ public function notification(array $notification = [])
4141

4242
return $this;
4343
}
44-
44+
4545
public function timeToLive(int $timeToLive)
4646
{
47+
if ($timeToLive < 0) {
48+
$timeToLive = 0; // (0 seconds)
49+
}
50+
if ($timeToLive > 2419200) {
51+
$timeToLive = 2419200; // (28 days)
52+
}
53+
4754
$this->timeToLive = $timeToLive;
48-
55+
4956
return $this;
5057
}
5158

@@ -65,7 +72,7 @@ public function send()
6572
} else {
6673
$payloads['registration_ids'] = $this->recipients;
6774
}
68-
75+
6976
if ($this->timeToLive !== null && $this->timeToLive >= 0) {
7077
$payloads['time_to_live'] = (int) $this->timeToLive;
7178
}

0 commit comments

Comments
 (0)