Skip to content

Commit 69d0d94

Browse files
krsqueDaniil Glushchenko
and
Daniil Glushchenko
authored
Add group related notification ID (#15)
Co-authored-by: Daniil Glushchenko <dgluschenko@belkacar.org>
1 parent 4b7d272 commit 69d0d94

File tree

8 files changed

+161
-38
lines changed

8 files changed

+161
-38
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
/phpdocumentor/
77
/build/
88
composer.lock
9+
.idea/

src/main/php/Gomoob/Pushwoosh/Model/Notification/Android.php

Lines changed: 54 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Android implements \JsonSerializable
2222
* @var int
2323
*/
2424
private $badges;
25-
25+
2626
private $banner;
2727
private $customIcon;
2828

@@ -33,24 +33,33 @@ class Android implements \JsonSerializable
3333
* @var int
3434
*/
3535
private $gcmTtl;
36+
37+
/**
38+
* Identifier to group related notifications.
39+
* Messages with the same thread ID will be grouped in the Notification Center.
40+
*
41+
* @var string|null
42+
*/
43+
private $groupId;
44+
3645
private $header;
37-
46+
3847
/**
3948
* The icon background color on Lollipop, #RRGGBB, #AARRGGBB, "red", "black", "yellow", etc.
4049
*
4150
* @var string
4251
*/
4352
private $ibc;
44-
53+
4554
private $icon;
46-
55+
4756
/**
4857
* The LED hex color, device will do its best approximation.
4958
*
5059
* @var string
5160
*/
5261
private $led;
53-
62+
5463
/**
5564
* The priority of the push in the Android push drawer, valid values are -2, -1, 0, 1 and 2.
5665
*
@@ -60,7 +69,7 @@ class Android implements \JsonSerializable
6069

6170
private $rootParams;
6271
private $sound;
63-
72+
6473
/**
6574
* A boolean used to force vibration for high-priority pushes.
6675
*
@@ -113,12 +122,20 @@ public function getGcmTtl()
113122

114123
}
115124

125+
/**
126+
* @return string|null
127+
*/
128+
public function getGroupId()
129+
{
130+
return $this->groupId;
131+
}
132+
116133
public function getHeader()
117134
{
118135
return $this->header;
119136

120137
}
121-
138+
122139
/**
123140
* Gets the icon background color on Lollipop, #RRGGBB, #AARRGGBB, "red", "black", "yellow", etc.
124141
*
@@ -133,7 +150,7 @@ public function getIcon()
133150
{
134151
return $this->icon;
135152
}
136-
153+
137154
/**
138155
* Gets the LED hex color, device will do its best approximation.
139156
*
@@ -143,7 +160,7 @@ public function getLed()
143160
{
144161
return $this->led;
145162
}
146-
163+
147164
/**
148165
* Gets priority of the push in the Android push drawer, valid values are -2, -1, 0, 1 and 2.
149166
*
@@ -163,7 +180,7 @@ public function getSound()
163180
{
164181
return $this->sound;
165182
}
166-
183+
167184
/**
168185
* Gets the boolean used to force vibration for high-priority pushes.
169186
*
@@ -173,14 +190,14 @@ public function isVibration()
173190
{
174191
return $this->vibration;
175192
}
176-
193+
177194
/**
178195
* {@inheritdoc}
179196
*/
180197
public function jsonSerialize()
181198
{
182199
$json = [];
183-
200+
184201
isset($this->badges) ? $json['android_badges'] = $this->badges : false;
185202
isset($this->banner) ? $json['android_banner'] = $this->banner : false;
186203
isset($this->customIcon) ? $json['android_custom_icon'] = $this->customIcon : false;
@@ -193,9 +210,13 @@ public function jsonSerialize()
193210
isset($this->rootParams) ? $json['android_root_params'] = $this->rootParams : false;
194211
isset($this->sound) ? $json['android_sound'] = $this->sound : false;
195212
isset($this->vibration) ? $json['android_vibration'] = ($this->vibration ? 1 : 0) : false;
196-
213+
214+
if ($this->groupId !== null) {
215+
$json['android_group_id'] = $this->groupId;
216+
}
217+
197218
return $json;
198-
219+
199220
}
200221

201222
/**
@@ -208,7 +229,7 @@ public function jsonSerialize()
208229
public function setBadges($badges)
209230
{
210231
$this->badges = $badges;
211-
232+
212233
return $this;
213234
}
214235

@@ -242,14 +263,24 @@ public function setGcmTtl($gcmTtl)
242263
return $this;
243264
}
244265

266+
/**
267+
* @param string|null $groupId
268+
*/
269+
public function setGroupId($groupId)
270+
{
271+
$this->groupId = $groupId;
272+
273+
return $this;
274+
}
275+
245276
public function setHeader($header)
246277
{
247278
$this->header = $header;
248279

249280
return $this;
250281

251282
}
252-
283+
253284
/**
254285
* Sets the icon background color on Lollipop, #RRGGBB, #AARRGGBB, "red", "black", "yellow", etc.
255286
*
@@ -260,7 +291,7 @@ public function setHeader($header)
260291
public function setIbc($ibc)
261292
{
262293
$this->ibc = $ibc;
263-
294+
264295
return $this;
265296
}
266297

@@ -270,7 +301,7 @@ public function setIcon($icon)
270301

271302
return $this;
272303
}
273-
304+
274305
/**
275306
* Sets the LED hex color, device will do its best approximation.
276307
*
@@ -281,10 +312,10 @@ public function setIcon($icon)
281312
public function setLed($led)
282313
{
283314
$this->led = $led;
284-
315+
285316
return $this;
286317
}
287-
318+
288319
/**
289320
* Sets the priority of the push in the Android push drawer, valid values are -2, -1, 0, 1 and 2.
290321
*
@@ -295,7 +326,7 @@ public function setLed($led)
295326
public function setPriority($priority)
296327
{
297328
$this->priority = $priority;
298-
329+
299330
return $this;
300331
}
301332

@@ -312,7 +343,7 @@ public function setSound($sound)
312343

313344
return $this;
314345
}
315-
346+
316347
/**
317348
* Sets the boolean used to force vibration for high-priority pushes.
318349
*
@@ -323,7 +354,7 @@ public function setSound($sound)
323354
public function setVibration($vibration)
324355
{
325356
$this->vibration = $vibration;
326-
357+
327358
return $this;
328359
}
329360
}

src/main/php/Gomoob/Pushwoosh/Model/Notification/Huawei.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ final class Huawei implements \JsonSerializable
2424
*/
2525
private $gcmTtl;
2626

27+
/**
28+
* @var string|null
29+
*/
30+
private $groupId;
31+
2732
/**
2833
* @var string|null
2934
*/
@@ -89,6 +94,14 @@ public function getGcmTtl()
8994
return $this->gcmTtl;
9095
}
9196

97+
/**
98+
* @return string|null
99+
*/
100+
public function getGroupId()
101+
{
102+
return $this->groupId;
103+
}
104+
92105
public function getHeader()
93106
{
94107
return $this->header;
@@ -149,6 +162,10 @@ public function jsonSerialize()
149162
$json['huawei_android_gcm_ttl'] = $this->gcmTtl;
150163
}
151164

165+
if ($this->groupId !== null) {
166+
$json['huawei_android_group_id'] = $this->groupId;
167+
}
168+
152169
if ($this->header !== null) {
153170
$json['huawei_android_header'] = $this->header;
154171
}
@@ -212,6 +229,16 @@ public function setGcmTtl($gcmTtl)
212229
return $this;
213230
}
214231

232+
/**
233+
* @param string|null $groupId
234+
*/
235+
public function setGroupId($groupId)
236+
{
237+
$this->groupId = $groupId;
238+
239+
return $this;
240+
}
241+
215242
public function setHeader($header)
216243
{
217244
$this->header = $header;

0 commit comments

Comments
 (0)