Skip to content

Commit

Permalink
Merge pull request #7 from hramos/feature/add-subtitle
Browse files Browse the repository at this point in the history
Add support for subtitle field (iOS)
  • Loading branch information
nicko170 authored Apr 2, 2023
2 parents e329199 + 002347f commit d9d3a66
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 d9d3a66

Please sign in to comment.