Skip to content

Commit d9d3a66

Browse files
authored
Merge pull request #7 from hramos/feature/add-subtitle
Add support for subtitle field (iOS)
2 parents e329199 + 002347f commit d9d3a66

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

Diff for: src/ExpoMessage.php

+23
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ class ExpoMessage
1313
*/
1414
protected $title;
1515

16+
/**
17+
* The message subtitle (iOS).
18+
*
19+
* @var string
20+
*/
21+
protected $subtitle;
22+
1623
/**
1724
* The message body.
1825
*
@@ -100,6 +107,19 @@ public function title(string $value): ExpoMessage
100107
return $this;
101108
}
102109

110+
/**
111+
* Set the message subtitle (iOS).
112+
*
113+
* @param string $value
114+
* @return $this
115+
*/
116+
public function subtitle(string $value): ExpoMessage
117+
{
118+
$this->subtitle = $value;
119+
120+
return $this;
121+
}
122+
103123
/**
104124
* Set the message body.
105125
*
@@ -230,6 +250,9 @@ public function toArray(): array
230250
'data' => $this->jsonData,
231251
'priority' => $this->priority,
232252
];
253+
if (! empty($this->subtitle)) {
254+
$message['subtitle'] = $this->subtitle;
255+
}
233256
if (! empty($this->channelId)) {
234257
$message['channelId'] = $this->channelId;
235258
}

Diff for: tests/ExpoMessageTest.php

+7
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ public function it_can_set_the_title()
4444
$this->assertEquals('Title', Arr::get($this->message->toArray(), 'title'));
4545
}
4646

47+
/** @test */
48+
public function it_can_set_the_subtitle()
49+
{
50+
$this->message->subtitle('Subtitle');
51+
$this->assertEquals('Subtitle', Arr::get($this->message->toArray(), 'subtitle'));
52+
}
53+
4754
/** @test */
4855
public function it_can_set_the_body()
4956
{

0 commit comments

Comments
 (0)