Skip to content

Commit

Permalink
Merge pull request #26 from erlangp/patch-7
Browse files Browse the repository at this point in the history
add ability to set lifetime of messages
  • Loading branch information
sayaamirul authored May 16, 2019
2 parents b51084b + ec950aa commit 034cff0
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Fcm.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Fcm
protected $topic;
protected $data;
protected $notification;
protected $timeToLive;

public function to(array $recipients)
{
Expand Down Expand Up @@ -40,6 +41,13 @@ public function notification(array $notification = [])

return $this;
}

public function timeToLive(int $timeToLive)
{
$this->timeToLive = $timeToLive;

return $this;
}

public function send()
{
Expand All @@ -57,6 +65,10 @@ public function send()
} else {
$payloads['registration_ids'] = $this->recipients;
}

if ($this->timeToLive !== null && $this->timeToLive >= 0) {
$payloads['time_to_live'] = (int) $this->timeToLive;
}

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

Expand Down

0 comments on commit 034cff0

Please sign in to comment.