Skip to content

Commit ab36a21

Browse files
krsqueDaniil Glushchenko
andauthored
Add group related notification ID (#16)
Co-authored-by: Daniil Glushchenko <[email protected]>
1 parent d47cbdb commit ab36a21

File tree

8 files changed

+144
-42
lines changed

8 files changed

+144
-42
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/vendor
22
.phpunit.result.cache
33
composer.lock
4+
.idea/

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

Lines changed: 46 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,31 @@ 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+
private ?string $groupId;
42+
3643
private $header;
37-
44+
3845
/**
3946
* The icon background color on Lollipop, #RRGGBB, #AARRGGBB, "red", "black", "yellow", etc.
4047
*
4148
* @var string
4249
*/
4350
private $ibc;
44-
51+
4552
private $icon;
46-
53+
4754
/**
4855
* The LED hex color, device will do its best approximation.
4956
*
5057
* @var string
5158
*/
5259
private $led;
53-
60+
5461
/**
5562
* The priority of the push in the Android push drawer, valid values are -2, -1, 0, 1 and 2.
5663
*
@@ -60,7 +67,7 @@ class Android implements \JsonSerializable
6067

6168
private $rootParams;
6269
private $sound;
63-
70+
6471
/**
6572
* A boolean used to force vibration for high-priority pushes.
6673
*
@@ -113,12 +120,17 @@ public function getGcmTtl()
113120

114121
}
115122

123+
public function getGroupId(): ?string
124+
{
125+
return $this->groupId;
126+
}
127+
116128
public function getHeader()
117129
{
118130
return $this->header;
119131

120132
}
121-
133+
122134
/**
123135
* Gets the icon background color on Lollipop, #RRGGBB, #AARRGGBB, "red", "black", "yellow", etc.
124136
*
@@ -133,7 +145,7 @@ public function getIcon()
133145
{
134146
return $this->icon;
135147
}
136-
148+
137149
/**
138150
* Gets the LED hex color, device will do its best approximation.
139151
*
@@ -143,7 +155,7 @@ public function getLed()
143155
{
144156
return $this->led;
145157
}
146-
158+
147159
/**
148160
* Gets priority of the push in the Android push drawer, valid values are -2, -1, 0, 1 and 2.
149161
*
@@ -163,7 +175,7 @@ public function getSound()
163175
{
164176
return $this->sound;
165177
}
166-
178+
167179
/**
168180
* Gets the boolean used to force vibration for high-priority pushes.
169181
*
@@ -173,14 +185,14 @@ public function isVibration()
173185
{
174186
return $this->vibration;
175187
}
176-
188+
177189
/**
178190
* {@inheritdoc}
179191
*/
180192
public function jsonSerialize(): mixed
181193
{
182194
$json = [];
183-
195+
184196
isset($this->badges) ? $json['android_badges'] = $this->badges : false;
185197
isset($this->banner) ? $json['android_banner'] = $this->banner : false;
186198
isset($this->customIcon) ? $json['android_custom_icon'] = $this->customIcon : false;
@@ -193,9 +205,13 @@ public function jsonSerialize(): mixed
193205
isset($this->rootParams) ? $json['android_root_params'] = $this->rootParams : false;
194206
isset($this->sound) ? $json['android_sound'] = $this->sound : false;
195207
isset($this->vibration) ? $json['android_vibration'] = ($this->vibration ? 1 : 0) : false;
196-
208+
209+
if ($this->groupId !== null) {
210+
$json['android_group_id'] = $this->groupId;
211+
}
212+
197213
return $json;
198-
214+
199215
}
200216

201217
/**
@@ -208,7 +224,7 @@ public function jsonSerialize(): mixed
208224
public function setBadges($badges)
209225
{
210226
$this->badges = $badges;
211-
227+
212228
return $this;
213229
}
214230

@@ -242,14 +258,21 @@ public function setGcmTtl($gcmTtl)
242258
return $this;
243259
}
244260

261+
public function setGroupId(?string $groupId): self
262+
{
263+
$this->groupId = $groupId;
264+
265+
return $this;
266+
}
267+
245268
public function setHeader($header)
246269
{
247270
$this->header = $header;
248271

249272
return $this;
250273

251274
}
252-
275+
253276
/**
254277
* Sets the icon background color on Lollipop, #RRGGBB, #AARRGGBB, "red", "black", "yellow", etc.
255278
*
@@ -260,7 +283,7 @@ public function setHeader($header)
260283
public function setIbc($ibc)
261284
{
262285
$this->ibc = $ibc;
263-
286+
264287
return $this;
265288
}
266289

@@ -270,7 +293,7 @@ public function setIcon($icon)
270293

271294
return $this;
272295
}
273-
296+
274297
/**
275298
* Sets the LED hex color, device will do its best approximation.
276299
*
@@ -281,10 +304,10 @@ public function setIcon($icon)
281304
public function setLed($led)
282305
{
283306
$this->led = $led;
284-
307+
285308
return $this;
286309
}
287-
310+
288311
/**
289312
* Sets the priority of the push in the Android push drawer, valid values are -2, -1, 0, 1 and 2.
290313
*
@@ -295,7 +318,7 @@ public function setLed($led)
295318
public function setPriority($priority)
296319
{
297320
$this->priority = $priority;
298-
321+
299322
return $this;
300323
}
301324

@@ -312,7 +335,7 @@ public function setSound($sound)
312335

313336
return $this;
314337
}
315-
338+
316339
/**
317340
* Sets the boolean used to force vibration for high-priority pushes.
318341
*
@@ -323,7 +346,7 @@ public function setSound($sound)
323346
public function setVibration($vibration)
324347
{
325348
$this->vibration = $vibration;
326-
349+
327350
return $this;
328351
}
329352
}

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

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

27+
/**
28+
* Identifier to group related notifications.
29+
* Messages with the same thread ID will be grouped in the Notification Center.
30+
*/
31+
private ?string $groupId;
32+
2733
/**
2834
* @var string|null
2935
*/
@@ -89,6 +95,11 @@ public function getGcmTtl()
8995
return $this->gcmTtl;
9096
}
9197

98+
public function getGroupId(): ?string
99+
{
100+
return $this->groupId;
101+
}
102+
92103
public function getHeader()
93104
{
94105
return $this->header;
@@ -149,6 +160,10 @@ public function jsonSerialize(): mixed
149160
$json['huawei_android_gcm_ttl'] = $this->gcmTtl;
150161
}
151162

163+
if ($this->groupId !== null) {
164+
$json['huawei_android_group_id'] = $this->groupId;
165+
}
166+
152167
if ($this->header !== null) {
153168
$json['huawei_android_header'] = $this->header;
154169
}
@@ -212,6 +227,13 @@ public function setGcmTtl($gcmTtl)
212227
return $this;
213228
}
214229

230+
public function setGroupId(?string $groupId): self
231+
{
232+
$this->groupId = $groupId;
233+
234+
return $this;
235+
}
236+
215237
public function setHeader($header)
216238
{
217239
$this->header = $header;

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

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,23 @@ class IOS implements \JsonSerializable
2323
private $apnsTrimContent;
2424

2525
private $badges;
26-
26+
2727
/**
2828
* The iOS 8 category ID from Pushwoosh.
2929
*
3030
* @var int
3131
*/
3232
private $categoryId;
33-
33+
3434
private $rootParams;
3535
private $sound;
36+
37+
/**
38+
* Identifier to group related notifications.
39+
* Messages with the same thread ID will be grouped on the lock screen and in the Notification Center.
40+
*/
41+
private ?string $threadId;
42+
3643
private $ttl;
3744
private $trimContent;
3845

@@ -50,7 +57,7 @@ public function getBadges()
5057
{
5158
return $this->badges;
5259
}
53-
60+
5461
/**
5562
* Gets the iOS 8 category ID from Pushwoosh.
5663
*
@@ -72,6 +79,11 @@ public function getSound()
7279

7380
}
7481

82+
public function getThreadId(): ?string
83+
{
84+
return $this->threadId;
85+
}
86+
7587
public function getTtl()
7688
{
7789
return $this->ttl;
@@ -93,24 +105,28 @@ public function isTrimContent()
93105
return $this->trimContent;
94106

95107
}
96-
108+
97109
/**
98110
* {@inheritdoc}
99111
*/
100112
public function jsonSerialize(): mixed
101113
{
102114
$json = [];
103-
115+
104116
isset($this->apnsTrimContent) ? $json['apns_trim_content'] = intval($this->apnsTrimContent) : false;
105117
isset($this->badges) ? $json['ios_badges'] = $this->badges : false;
106118
isset($this->categoryId) ? $json['ios_category_id'] = $this->categoryId : false;
107119
isset($this->rootParams) ? $json['ios_root_params'] = $this->rootParams : false;
108120
isset($this->sound) ? $json['ios_sound'] = $this->sound : false;
109121
isset($this->ttl) ? $json['ios_ttl'] = $this->ttl : false;
110122
isset($this->trimContent) ? $json['ios_trim_content'] = intval($this->trimContent) : false;
111-
123+
124+
if ($this->threadId !== null) {
125+
$json['ios_thread_id'] = $this->threadId;
126+
}
127+
112128
return $json;
113-
129+
114130
}
115131

116132
/**
@@ -135,7 +151,7 @@ public function setBadges($badges)
135151
return $this;
136152

137153
}
138-
154+
139155
/**
140156
* Sets the iOS 8 category ID from Pushwoosh.
141157
*
@@ -146,7 +162,7 @@ public function setBadges($badges)
146162
public function setCategoryId($categoryId)
147163
{
148164
$this->categoryId = $categoryId;
149-
165+
150166
return $this;
151167
}
152168

@@ -165,6 +181,13 @@ public function setSound($sound)
165181
return $this;
166182
}
167183

184+
public function setThreadId(?string $threadId): self
185+
{
186+
$this->threadId = $threadId;
187+
188+
return $this;
189+
}
190+
168191
public function setTtl($ttl)
169192
{
170193
$this->ttl = $ttl;

0 commit comments

Comments
 (0)