Skip to content

Commit

Permalink
Add group related notification ID (#15)
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 4b7d272 commit 69d0d94
Show file tree
Hide file tree
Showing 8 changed files with 161 additions and 38 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
/phpdocumentor/
/build/
composer.lock
.idea/
77 changes: 54 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,33 @@ 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.
*
* @var string|null
*/
private $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 +69,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 +122,20 @@ public function getGcmTtl()

}

/**
* @return string|null
*/
public function getGroupId()
{
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 +150,7 @@ public function getIcon()
{
return $this->icon;
}

/**
* Gets the LED hex color, device will do its best approximation.
*
Expand All @@ -143,7 +160,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 +180,7 @@ public function getSound()
{
return $this->sound;
}

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

/**
* {@inheritdoc}
*/
public function jsonSerialize()
{
$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 +210,13 @@ public function jsonSerialize()
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 +229,7 @@ public function jsonSerialize()
public function setBadges($badges)
{
$this->badges = $badges;

return $this;
}

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

/**
* @param string|null $groupId
*/
public function setGroupId($groupId)
{
$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 +291,7 @@ public function setHeader($header)
public function setIbc($ibc)
{
$this->ibc = $ibc;

return $this;
}

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

return $this;
}

/**
* Sets the LED hex color, device will do its best approximation.
*
Expand All @@ -281,10 +312,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 +326,7 @@ public function setLed($led)
public function setPriority($priority)
{
$this->priority = $priority;

return $this;
}

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

return $this;
}

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

return $this;
}
}
27 changes: 27 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,11 @@ final class Huawei implements \JsonSerializable
*/
private $gcmTtl;

/**
* @var string|null
*/
private $groupId;

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

/**
* @return string|null
*/
public function getGroupId()
{
return $this->groupId;
}

public function getHeader()
{
return $this->header;
Expand Down Expand Up @@ -149,6 +162,10 @@ public function jsonSerialize()
$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 +229,16 @@ public function setGcmTtl($gcmTtl)
return $this;
}

/**
* @param string|null $groupId
*/
public function setGroupId($groupId)
{
$this->groupId = $groupId;

return $this;
}

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

0 comments on commit 69d0d94

Please sign in to comment.