Skip to content

Commit 58b9a4d

Browse files
committed
Add new Notification properties
1 parent 75f2972 commit 58b9a4d

File tree

1 file changed

+88
-1
lines changed

1 file changed

+88
-1
lines changed

src/Notification.php

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,20 @@
77
class Notification extends Message
88
{
99
private $title;
10+
private $subtitle;
1011
private $body;
1112
private $badge;
1213
private $icon;
1314
private $color;
1415
private $sound;
1516
private $clickAction;
1617
private $tag;
18+
private $contentAvailable;
19+
private $bodyLocKey;
20+
private $bodyLocArgs;
21+
private $titleLocKey;
22+
private $titleLocArgs;
23+
private $androidChannelId;
1724

1825
public function __construct($title = '', $body = '')
1926
{
@@ -90,14 +97,72 @@ public function setTag($tag)
9097
return $this;
9198
}
9299

100+
public function setContentAvailable($contentAvailable)
101+
{
102+
$this->contentAvailable = $contentAvailable;
103+
return $this;
104+
}
105+
106+
public function setSubtitle($subtitle)
107+
{
108+
$this->subtitle = $subtitle;
109+
return $this;
110+
}
111+
112+
public function setBodyLocKey($bodyLocKey)
113+
{
114+
$this->bodyLocKey = $bodyLocKey;
115+
return $this;
116+
}
117+
118+
public function setBodyLocArgs($bodyLocArgs)
119+
{
120+
$this->bodyLocArgs = $bodyLocArgs;
121+
return $this;
122+
}
123+
124+
public function setTitleLocKey($titleLocKey)
125+
{
126+
$this->titleLocKey = $titleLocKey;
127+
return $this;
128+
}
129+
130+
public function setTitleLocArgs($titleLocArgs)
131+
{
132+
$this->titleLocArgs = $titleLocArgs;
133+
return $this;
134+
}
135+
136+
public function setAndroidChannelId($androidChannelId)
137+
{
138+
$this->androidChannelId = $androidChannelId;
139+
return $this;
140+
}
141+
93142
public function hasNotificationData()
94143
{
95-
return $this->title || $this->body || $this->badge || $this->icon || $this->clickAction || $this->sound || $this->tag;
144+
return
145+
$this->title ||
146+
$this->body ||
147+
$this->badge ||
148+
$this->icon ||
149+
$this->clickAction ||
150+
$this->sound ||
151+
$this->tag ||
152+
$this->contentAvailable ||
153+
$this->subtitle ||
154+
$this->titleLocKey ||
155+
$this->titleLocArgs ||
156+
$this->bodyLocKey ||
157+
$this->bodyLocArgs ||
158+
$this->androidChannelId
159+
;
96160
}
97161

98162
public function jsonSerialize()
99163
{
100164
$jsonData = [];
165+
101166
if ($this->title) {
102167
$jsonData['title'] = $this->title;
103168
}
@@ -122,6 +187,28 @@ public function jsonSerialize()
122187
if ($this->tag) {
123188
$jsonData['tag'] = $this->tag;
124189
}
190+
if ($this->contentAvailable) {
191+
$jsonData['content_available'] = $this->contentAvailable;
192+
}
193+
if ($this->subtitle) {
194+
$jsonData['subtitle'] = $this->subtitle;
195+
}
196+
if ($this->androidChannelId) {
197+
$jsonData['android_channel_id'] = $this->androidChannelId;
198+
}
199+
if ($this->titleLocKey) {
200+
$jsonData['title_loc_key'] = $this->titleLocKey;
201+
}
202+
if ($this->titleLocArgs) {
203+
$jsonData['title_loc_args'] = $this->titleLocArgs;
204+
}
205+
if ($this->bodyLocKey) {
206+
$jsonData['body_loc_key'] = $this->bodyLocKey;
207+
}
208+
if ($this->bodyLocArgs) {
209+
$jsonData['body_loc_args'] = $this->bodyLocArgs;
210+
}
211+
125212
return $jsonData;
126213
}
127214
}

0 commit comments

Comments
 (0)