From 836d811c78bc62d6eeb18ee7e70b5f4d56b403c8 Mon Sep 17 00:00:00 2001 From: Dees Oomens Date: Fri, 18 Mar 2022 10:36:39 +0100 Subject: [PATCH 1/2] Send notifications to multiple interests --- .gitignore | 3 ++- src/ExpoChannel.php | 3 ++- tests/ChannelTest.php | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index d13e72b1..b257298b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ build composer.phar composer.lock -.idea \ No newline at end of file +.idea +.phpunit.result.cache diff --git a/src/ExpoChannel.php b/src/ExpoChannel.php index b0499d9f..1d8d7ba4 100644 --- a/src/ExpoChannel.php +++ b/src/ExpoChannel.php @@ -7,6 +7,7 @@ use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Notifications\Events\NotificationFailed; use Illuminate\Notifications\Notification; +use Illuminate\Support\Arr; use NotificationChannels\ExpoPushNotifications\Exceptions\CouldNotSendNotification; class ExpoChannel @@ -47,7 +48,7 @@ public function send($notifiable, Notification $notification) $interest = $notifiable->routeNotificationFor('ExpoPushNotifications') ?: $this->interestName($notifiable); - $interests = [$interest]; + $interests = Arr::wrap($interest); try { $this->expo->notify( diff --git a/tests/ChannelTest.php b/tests/ChannelTest.php index 710c0d2a..a359334f 100644 --- a/tests/ChannelTest.php +++ b/tests/ChannelTest.php @@ -73,6 +73,24 @@ public function itCanSendANotification() $this->channel->send($this->notifiable, $this->notification); } + /** @test */ + public function itCanSendANNotificationToMultipleInterests() + { + $this->notifiable = Mockery::mock($this->notifiable); + + $this->notifiable->shouldReceive('routeNotificationFor') + ->with('ExpoPushNotifications') + ->andReturn($interests = ['interest_1', 'interest_2']); + + $message = $this->notification->toExpoPush($this->notifiable); + + $data = $message->toArray(); + + $this->expo->shouldReceive('notify')->with($interests, $data, true)->andReturn([['status' => 'ok']]); + + $this->channel->send($this->notifiable, $this->notification); + } + /** @test */ public function itFiresFailureEventOnFailure() { From 8a263fa94ccf3bec3db4ed86327be3625f034f81 Mon Sep 17 00:00:00 2001 From: Younes el Barnoussi Date: Fri, 24 Feb 2023 17:21:54 +0300 Subject: [PATCH 2/2] Laravel 10 support --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 70799a5c..c7d37b38 100644 --- a/composer.json +++ b/composer.json @@ -13,12 +13,12 @@ "require": { "php": "^8.0", "alymosul/exponent-server-sdk-php": "1.3.*", - "laravel/framework": "^9.0" + "laravel/framework": "^9.0|^10.0" }, "require-dev": { "mockery/mockery": "^1.5.0", "phpunit/phpunit": "^9.0", - "orchestra/testbench": "^7.1.0" + "orchestra/testbench": "^7.1.0|^8.0" }, "autoload": { "psr-4": {