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() {