Skip to content

Commit

Permalink
Safari notifications support (#115)
Browse files Browse the repository at this point in the history
* Added support for the url-args field of Safari notifications.
  • Loading branch information
marcorocca authored Oct 28, 2020
1 parent b69afbc commit 26655b8
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/Payload.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class Payload implements \JsonSerializable
const PAYLOAD_MUTABLE_CONTENT_KEY = 'mutable-content';
const PAYLOAD_CATEGORY_KEY = 'category';
const PAYLOAD_THREAD_ID_KEY = 'thread-id';
const PAYLOAD_URL_ARGS_KEY = 'url-args';

const PAYLOAD_HTTP2_REGULAR_NOTIFICATION_MAXIMUM_SIZE = 4096;
const PAYLOAD_HTTP2_VOIP_NOTIFICATION_MAXIMUM_SIZE = 5120;
Expand Down Expand Up @@ -94,6 +95,13 @@ class Payload implements \JsonSerializable
*/
private $threadId;

/**
* Provide this key with an array value that represents the url-args for Safari notifications.
*
* @var string
*/
private $urlArgs;

/**
* Payload custom values.
*
Expand Down Expand Up @@ -294,6 +302,30 @@ public function setThreadId(string $value): Payload
return $this;
}

/**
* Get url-args.
*
* @return array|null
*/
public function getUrlArgs()
{
return $this->urlArgs;
}

/**
* Set url-args.
*
* @param array $value
*
* @return Payload
*/
public function setUrlArgs(array $value): Payload
{
$this->urlArgs = $value;

return $this;
}

/**
* Set custom value for Payload.
*
Expand Down Expand Up @@ -400,6 +432,10 @@ public function jsonSerialize()
$payload[self::PAYLOAD_ROOT_KEY]->{self::PAYLOAD_THREAD_ID_KEY} = $this->threadId;
}

if (is_array($this->urlArgs)) {
$payload[self::PAYLOAD_ROOT_KEY]->{self::PAYLOAD_URL_ARGS_KEY} = $this->urlArgs;
}

if (is_countable($this->customValues) && count($this->customValues)) {
$payload = array_merge($payload, $this->customValues);
}
Expand Down

0 comments on commit 26655b8

Please sign in to comment.