Skip to content

Commit

Permalink
Add content available flag
Browse files Browse the repository at this point in the history
  • Loading branch information
abnegate committed Dec 3, 2024
1 parent f6790fb commit 0e5321f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Utopia/Messaging/Adapter/Push/APNS.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public function process(PushMessage $message): array
'badge' => $message->getBadge(),
'sound' => $message->getSound(),
'data' => $message->getData(),
'content-available' => (int)$message->getContentAvailable(),
],
];

Expand Down
3 changes: 3 additions & 0 deletions src/Utopia/Messaging/Adapter/Push/FCM.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ protected function process(PushMessage $message): array
if (!\is_null($message->getBadge())) {
$shared['message']['apns']['payload']['aps']['badge'] = $message->getBadge();
}
if (!\is_null($message->getContentAvailable())) {
$shared['message']['apns']['payload']['aps']['content-available'] = (int)$message->getContentAvailable();
}

$bodies = [];

Expand Down
6 changes: 6 additions & 0 deletions src/Utopia/Messaging/Messages/Push.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public function __construct(
private ?string $color = null,
private ?string $tag = null,
private ?int $badge = null,
private ?bool $contentAvailable = null
) {
}

Expand Down Expand Up @@ -99,4 +100,9 @@ public function getBadge(): ?int
{
return $this->badge;
}

public function getContentAvailable(): ?bool
{
return $this->contentAvailable;
}
}
3 changes: 2 additions & 1 deletion tests/Messaging/Adapter/Push/APNSTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public function testSend(): void
icon: null,
color: null,
tag: null,
badge: 1
badge: 1,
contentAvailable: true
);

$response = $adapter->send($message);
Expand Down

0 comments on commit 0e5321f

Please sign in to comment.