Skip to content

Commit

Permalink
Add support for subtitle field.
Browse files Browse the repository at this point in the history
  • Loading branch information
hramos committed Mar 16, 2023
1 parent e329199 commit 002347f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/ExpoMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ class ExpoMessage
*/
protected $title;

/**
* The message subtitle (iOS).
*
* @var string
*/
protected $subtitle;

/**
* The message body.
*
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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;
}
Expand Down
7 changes: 7 additions & 0 deletions tests/ExpoMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down

0 comments on commit 002347f

Please sign in to comment.