diff --git a/src/Message.php b/src/Message.php index e39f13a..12d0dc5 100644 --- a/src/Message.php +++ b/src/Message.php @@ -28,6 +28,7 @@ class Message implements \JsonSerializable private $recipientType; private $timeToLive; private $delayWhileIdle; + private $restrictedPackageName; /** * Represents the app's "Send-to-Sync" message. @@ -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 * @@ -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; } diff --git a/src/Notification.php b/src/Notification.php index 812444d..ff07951 100644 --- a/src/Notification.php +++ b/src/Notification.php @@ -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) {