Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Message implements \JsonSerializable
private $recipientType;
private $timeToLive;
private $delayWhileIdle;
private $restrictedPackageName;

/**
* Represents the app's "Send-to-Sync" message.
Expand Down Expand Up @@ -69,6 +70,21 @@ public function setNotification(Notification $notification)
return $this;
}

/**
* Custom package name
*
* @see https://firebase.google.com/docs/cloud-messaging/http-server-ref#table1
*
* @param string $package_name
*
* @return \paragraph1\phpFCM\Message
*/
public function setRestrictedPackageName($package_name)
{
$this->restrictedPackageName = $package_name;
return $this;
}

/**
* @see https://firebase.google.com/docs/cloud-messaging/concept-options#collapsible_and_non-collapsible_messages
*
Expand Down Expand Up @@ -169,6 +185,9 @@ public function jsonSerialize()
if ($this->contentAvailableFlag === TRUE) {
$jsonData['content_available'] = TRUE;
}
if ($this->restrictedPackageName) {
$jsonData['restricted_package_name'] = $this->restrictedPackageName;
}

return $jsonData;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function jsonSerialize()

$jsonData['body'] = $this->body;

if ($this->badge) {
if (is_int($this->badge)) {
$jsonData['badge'] = $this->badge;
}
if ($this->icon) {
Expand Down