diff --git a/src/Utopia/Messaging/Adapter/Push/APNS.php b/src/Utopia/Messaging/Adapter/Push/APNS.php index d55e627..015909e 100644 --- a/src/Utopia/Messaging/Adapter/Push/APNS.php +++ b/src/Utopia/Messaging/Adapter/Push/APNS.php @@ -53,6 +53,7 @@ public function process(PushMessage $message): array 'badge' => $message->getBadge(), 'sound' => $message->getSound(), 'data' => $message->getData(), + 'content-available' => (int)$message->getContentAvailable(), ], ]; diff --git a/src/Utopia/Messaging/Adapter/Push/FCM.php b/src/Utopia/Messaging/Adapter/Push/FCM.php index 691bf1e..f221685 100644 --- a/src/Utopia/Messaging/Adapter/Push/FCM.php +++ b/src/Utopia/Messaging/Adapter/Push/FCM.php @@ -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 = []; diff --git a/src/Utopia/Messaging/Messages/Push.php b/src/Utopia/Messaging/Messages/Push.php index b517286..68faa5d 100644 --- a/src/Utopia/Messaging/Messages/Push.php +++ b/src/Utopia/Messaging/Messages/Push.php @@ -31,6 +31,7 @@ public function __construct( private ?string $color = null, private ?string $tag = null, private ?int $badge = null, + private ?bool $contentAvailable = null ) { } @@ -99,4 +100,9 @@ public function getBadge(): ?int { return $this->badge; } + + public function getContentAvailable(): ?bool + { + return $this->contentAvailable; + } } diff --git a/tests/Messaging/Adapter/Push/APNSTest.php b/tests/Messaging/Adapter/Push/APNSTest.php index 5216453..2fe11fb 100644 --- a/tests/Messaging/Adapter/Push/APNSTest.php +++ b/tests/Messaging/Adapter/Push/APNSTest.php @@ -27,7 +27,8 @@ public function testSend(): void icon: null, color: null, tag: null, - badge: 1 + badge: 1, + contentAvailable: true ); $response = $adapter->send($message);