Skip to content

Commit

Permalink
Add group related notification ID (#16)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniil Glushchenko <dgluschenko@belkacar.org>
  • Loading branch information
krsque and Daniil Glushchenko authored Jun 19, 2024
1 parent d47cbdb commit ab36a21
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 42 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/vendor
.phpunit.result.cache
composer.lock
.idea/
69 changes: 46 additions & 23 deletions src/main/php/Gomoob/Pushwoosh/Model/Notification/Android.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Android implements \JsonSerializable
* @var int
*/
private $badges;

private $banner;
private $customIcon;

Expand All @@ -33,24 +33,31 @@ class Android implements \JsonSerializable
* @var int
*/
private $gcmTtl;

/**
* Identifier to group related notifications.
* Messages with the same thread ID will be grouped in the Notification Center.
*/
private ?string $groupId;

private $header;

/**
* The icon background color on Lollipop, #RRGGBB, #AARRGGBB, "red", "black", "yellow", etc.
*
* @var string
*/
private $ibc;

private $icon;

/**
* The LED hex color, device will do its best approximation.
*
* @var string
*/
private $led;

/**
* The priority of the push in the Android push drawer, valid values are -2, -1, 0, 1 and 2.
*
Expand All @@ -60,7 +67,7 @@ class Android implements \JsonSerializable

private $rootParams;
private $sound;

/**
* A boolean used to force vibration for high-priority pushes.
*
Expand Down Expand Up @@ -113,12 +120,17 @@ public function getGcmTtl()

}

public function getGroupId(): ?string
{
return $this->groupId;
}

public function getHeader()
{
return $this->header;

}

/**
* Gets the icon background color on Lollipop, #RRGGBB, #AARRGGBB, "red", "black", "yellow", etc.
*
Expand All @@ -133,7 +145,7 @@ public function getIcon()
{
return $this->icon;
}

/**
* Gets the LED hex color, device will do its best approximation.
*
Expand All @@ -143,7 +155,7 @@ public function getLed()
{
return $this->led;
}

/**
* Gets priority of the push in the Android push drawer, valid values are -2, -1, 0, 1 and 2.
*
Expand All @@ -163,7 +175,7 @@ public function getSound()
{
return $this->sound;
}

/**
* Gets the boolean used to force vibration for high-priority pushes.
*
Expand All @@ -173,14 +185,14 @@ public function isVibration()
{
return $this->vibration;
}

/**
* {@inheritdoc}
*/
public function jsonSerialize(): mixed
{
$json = [];

isset($this->badges) ? $json['android_badges'] = $this->badges : false;
isset($this->banner) ? $json['android_banner'] = $this->banner : false;
isset($this->customIcon) ? $json['android_custom_icon'] = $this->customIcon : false;
Expand All @@ -193,9 +205,13 @@ public function jsonSerialize(): mixed
isset($this->rootParams) ? $json['android_root_params'] = $this->rootParams : false;
isset($this->sound) ? $json['android_sound'] = $this->sound : false;
isset($this->vibration) ? $json['android_vibration'] = ($this->vibration ? 1 : 0) : false;


if ($this->groupId !== null) {
$json['android_group_id'] = $this->groupId;
}

return $json;

}

/**
Expand All @@ -208,7 +224,7 @@ public function jsonSerialize(): mixed
public function setBadges($badges)
{
$this->badges = $badges;

return $this;
}

Expand Down Expand Up @@ -242,14 +258,21 @@ public function setGcmTtl($gcmTtl)
return $this;
}

public function setGroupId(?string $groupId): self
{
$this->groupId = $groupId;

return $this;
}

public function setHeader($header)
{
$this->header = $header;

return $this;

}

/**
* Sets the icon background color on Lollipop, #RRGGBB, #AARRGGBB, "red", "black", "yellow", etc.
*
Expand All @@ -260,7 +283,7 @@ public function setHeader($header)
public function setIbc($ibc)
{
$this->ibc = $ibc;

return $this;
}

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

return $this;
}

/**
* Sets the LED hex color, device will do its best approximation.
*
Expand All @@ -281,10 +304,10 @@ public function setIcon($icon)
public function setLed($led)
{
$this->led = $led;

return $this;
}

/**
* Sets the priority of the push in the Android push drawer, valid values are -2, -1, 0, 1 and 2.
*
Expand All @@ -295,7 +318,7 @@ public function setLed($led)
public function setPriority($priority)
{
$this->priority = $priority;

return $this;
}

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

return $this;
}

/**
* Sets the boolean used to force vibration for high-priority pushes.
*
Expand All @@ -323,7 +346,7 @@ public function setSound($sound)
public function setVibration($vibration)
{
$this->vibration = $vibration;

return $this;
}
}
22 changes: 22 additions & 0 deletions src/main/php/Gomoob/Pushwoosh/Model/Notification/Huawei.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ final class Huawei implements \JsonSerializable
*/
private $gcmTtl;

/**
* Identifier to group related notifications.
* Messages with the same thread ID will be grouped in the Notification Center.
*/
private ?string $groupId;

/**
* @var string|null
*/
Expand Down Expand Up @@ -89,6 +95,11 @@ public function getGcmTtl()
return $this->gcmTtl;
}

public function getGroupId(): ?string
{
return $this->groupId;
}

public function getHeader()
{
return $this->header;
Expand Down Expand Up @@ -149,6 +160,10 @@ public function jsonSerialize(): mixed
$json['huawei_android_gcm_ttl'] = $this->gcmTtl;
}

if ($this->groupId !== null) {
$json['huawei_android_group_id'] = $this->groupId;
}

if ($this->header !== null) {
$json['huawei_android_header'] = $this->header;
}
Expand Down Expand Up @@ -212,6 +227,13 @@ public function setGcmTtl($gcmTtl)
return $this;
}

public function setGroupId(?string $groupId): self
{
$this->groupId = $groupId;

return $this;
}

public function setHeader($header)
{
$this->header = $header;
Expand Down
41 changes: 32 additions & 9 deletions src/main/php/Gomoob/Pushwoosh/Model/Notification/IOS.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,23 @@ class IOS implements \JsonSerializable
private $apnsTrimContent;

private $badges;

/**
* The iOS 8 category ID from Pushwoosh.
*
* @var int
*/
private $categoryId;

private $rootParams;
private $sound;

/**
* Identifier to group related notifications.
* Messages with the same thread ID will be grouped on the lock screen and in the Notification Center.
*/
private ?string $threadId;

private $ttl;
private $trimContent;

Expand All @@ -50,7 +57,7 @@ public function getBadges()
{
return $this->badges;
}

/**
* Gets the iOS 8 category ID from Pushwoosh.
*
Expand All @@ -72,6 +79,11 @@ public function getSound()

}

public function getThreadId(): ?string
{
return $this->threadId;
}

public function getTtl()
{
return $this->ttl;
Expand All @@ -93,24 +105,28 @@ public function isTrimContent()
return $this->trimContent;

}

/**
* {@inheritdoc}
*/
public function jsonSerialize(): mixed
{
$json = [];

isset($this->apnsTrimContent) ? $json['apns_trim_content'] = intval($this->apnsTrimContent) : false;
isset($this->badges) ? $json['ios_badges'] = $this->badges : false;
isset($this->categoryId) ? $json['ios_category_id'] = $this->categoryId : false;
isset($this->rootParams) ? $json['ios_root_params'] = $this->rootParams : false;
isset($this->sound) ? $json['ios_sound'] = $this->sound : false;
isset($this->ttl) ? $json['ios_ttl'] = $this->ttl : false;
isset($this->trimContent) ? $json['ios_trim_content'] = intval($this->trimContent) : false;


if ($this->threadId !== null) {
$json['ios_thread_id'] = $this->threadId;
}

return $json;

}

/**
Expand All @@ -135,7 +151,7 @@ public function setBadges($badges)
return $this;

}

/**
* Sets the iOS 8 category ID from Pushwoosh.
*
Expand All @@ -146,7 +162,7 @@ public function setBadges($badges)
public function setCategoryId($categoryId)
{
$this->categoryId = $categoryId;

return $this;
}

Expand All @@ -165,6 +181,13 @@ public function setSound($sound)
return $this;
}

public function setThreadId(?string $threadId): self
{
$this->threadId = $threadId;

return $this;
}

public function setTtl($ttl)
{
$this->ttl = $ttl;
Expand Down
Loading

0 comments on commit ab36a21

Please sign in to comment.