From 002347fe0dc8615a5bfeed7b9c251b8945e4b533 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20O=2E=20Ramos=20Ortiz?= Date: Wed, 15 Mar 2023 22:29:36 -0700 Subject: [PATCH] Add support for subtitle field. --- src/ExpoMessage.php | 23 +++++++++++++++++++++++ tests/ExpoMessageTest.php | 7 +++++++ 2 files changed, 30 insertions(+) diff --git a/src/ExpoMessage.php b/src/ExpoMessage.php index b04def5..ca0b695 100644 --- a/src/ExpoMessage.php +++ b/src/ExpoMessage.php @@ -13,6 +13,13 @@ class ExpoMessage */ protected $title; + /** + * The message subtitle (iOS). + * + * @var string + */ + protected $subtitle; + /** * The message body. * @@ -100,6 +107,19 @@ public function title(string $value): ExpoMessage return $this; } + /** + * Set the message subtitle (iOS). + * + * @param string $value + * @return $this + */ + public function subtitle(string $value): ExpoMessage + { + $this->subtitle = $value; + + return $this; + } + /** * Set the message body. * @@ -230,6 +250,9 @@ public function toArray(): array 'data' => $this->jsonData, 'priority' => $this->priority, ]; + if (! empty($this->subtitle)) { + $message['subtitle'] = $this->subtitle; + } if (! empty($this->channelId)) { $message['channelId'] = $this->channelId; } diff --git a/tests/ExpoMessageTest.php b/tests/ExpoMessageTest.php index c7e7254..7b9527e 100644 --- a/tests/ExpoMessageTest.php +++ b/tests/ExpoMessageTest.php @@ -44,6 +44,13 @@ public function it_can_set_the_title() $this->assertEquals('Title', Arr::get($this->message->toArray(), 'title')); } + /** @test */ + public function it_can_set_the_subtitle() + { + $this->message->subtitle('Subtitle'); + $this->assertEquals('Subtitle', Arr::get($this->message->toArray(), 'subtitle')); + } + /** @test */ public function it_can_set_the_body() {