diff --git a/src/Message.php b/src/Message.php index 63d5a1c..973e609 100644 --- a/src/Message.php +++ b/src/Message.php @@ -174,7 +174,7 @@ public function jsonSerialize() if ($this->contentAvailable) { $jsonData['content_available'] = $this->contentAvailable; } - if ($this->notification) { + if ($this->notification && $this->notification->hasNotificationData()) { $jsonData['notification'] = $this->notification; } diff --git a/src/Notification.php b/src/Notification.php index cb0b289..0cd3a82 100644 --- a/src/Notification.php +++ b/src/Notification.php @@ -77,9 +77,14 @@ public function setTag($tag) return $this; } + public function hasNotificationData() + { + return $this->title || $this->body || $this->badge || $this->icon || $this->clickAction || $this->sound || $this->tag; + } + public function jsonSerialize() { - $jsonData = $this->getJsonData(); + $jsonData = []; if ($this->title) { $jsonData['title'] = $this->title; }